[ Sasha's backport helper bot ]
Hi,
The upstream commit SHA1 provided is correct: 32f123a3f34283f9c6446de87861696f0502b02e
WARNING: Author mismatch between patch and upstream commit: Backport author: Jakub Acs acsjakub@amazon.com Commit author: Jan Kara jack@suse.cz
Status in newer kernel trees: 6.12.y | Present (exact SHA1) 6.11.y | Present (exact SHA1) 6.6.y | Present (exact SHA1) 6.1.y | Not found
Note: The patch differs from the upstream commit: --- 1: 32f123a3f3428 ! 1: 8293ff38b97ef udf: Fold udf_getblk() into udf_bread() @@ ## Metadata ## -Author: Jan Kara jack@suse.cz +Author: Jakub Acs acsjakub@amazon.com
## Commit message ## udf: Fold udf_getblk() into udf_bread()
+ commit 32f123a3f34283f9c6446de87861696f0502b02e upstream. + udf_getblk() has a single call site. Fold it there.
Signed-off-by: Jan Kara jack@suse.cz
+ [acsjakub: backport-adjusting changes] + udf_getblk() has changed between 6.1 and the backported commit, namely + in commit 541e047b14c8 ("udf: Use udf_map_block() in udf_getblk()") + + Backport using the form of udf_getblk present in 6.1., that means use + udf_get_block() instead of udf_map_block() and use dummy in buffer_new() + and buffer_mapped(). + + Closes: https://syzkaller.appspot.com/bug?extid=a38e34ca637c224f4a79 + Signed-off-by: Jakub Acs acsjakub@amazon.de + ## fs/udf/inode.c ## @@ fs/udf/inode.c: static int udf_get_block(struct inode *inode, sector_t block, - return 0; + return err; }
-static struct buffer_head *udf_getblk(struct inode *inode, udf_pblk_t block, - int create, int *err) -{ - struct buffer_head *bh; -- struct udf_map_rq map = { -- .lblk = block, -- .iflags = UDF_MAP_NOPREALLOC | (create ? UDF_MAP_CREATE : 0), -- }; +- struct buffer_head dummy; - -- *err = udf_map_block(inode, &map); -- if (!*err && map.oflags & UDF_BLK_MAPPED) { -- bh = sb_getblk(inode->i_sb, map.pblk); -- if (map.oflags & UDF_BLK_NEW) { +- dummy.b_state = 0; +- dummy.b_blocknr = -1000; +- *err = udf_get_block(inode, block, &dummy, create); +- if (!*err && buffer_mapped(&dummy)) { +- bh = sb_getblk(inode->i_sb, dummy.b_blocknr); +- if (buffer_new(&dummy)) { - lock_buffer(bh); - memset(bh->b_data, 0x00, inode->i_sb->s_blocksize); - set_buffer_uptodate(bh); @@ fs/udf/inode.c: static int udf_get_block(struct inode *inode, sector_t block, - - return NULL; -} -- + /* Extend the file with new blocks totaling 'new_block_bytes', * return the number of extents added - */ @@ fs/udf/inode.c: struct buffer_head *udf_bread(struct inode *inode, udf_pblk_t block, int create, int *err) { struct buffer_head *bh = NULL; -+ struct udf_map_rq map = { -+ .lblk = block, -+ .iflags = UDF_MAP_NOPREALLOC | (create ? UDF_MAP_CREATE : 0), -+ }; ++ struct buffer_head dummy;
- bh = udf_getblk(inode, block, create, err); - if (!bh) -+ *err = udf_map_block(inode, &map); -+ if (*err || !(map.oflags & UDF_BLK_MAPPED)) ++ dummy.b_state = 0; ++ dummy.b_blocknr = -1000; ++ ++ *err = udf_get_block(inode, block, &dummy, create); ++ if (*err || !buffer_mapped(&dummy)) return NULL;
-+ bh = sb_getblk(inode->i_sb, map.pblk); ++ bh = sb_getblk(inode->i_sb, dummy.b_blocknr); + if (!bh) { + *err = -ENOMEM; + return NULL; + } -+ if (map.oflags & UDF_BLK_NEW) { ++ ++ if (buffer_new(&dummy)) { + lock_buffer(bh); + memset(bh->b_data, 0x00, inode->i_sb->s_blocksize); + set_buffer_uptodate(bh); ---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.1.y | Success | Success |