sst-linux/fs/nilfs2
Ryusuke Konishi 1ee2d454ba nilfs2: handle errors that nilfs_prepare_chunk() may return
commit ee70999a988b8abc3490609142f50ebaa8344432 upstream.

Patch series "nilfs2: fix issues with rename operations".

This series fixes BUG_ON check failures reported by syzbot around rename
operations, and a minor behavioral issue where the mtime of a child
directory changes when it is renamed instead of moved.


This patch (of 2):

The directory manipulation routines nilfs_set_link() and
nilfs_delete_entry() rewrite the directory entry in the folio/page
previously read by nilfs_find_entry(), so error handling is omitted on the
assumption that nilfs_prepare_chunk(), which prepares the buffer for
rewriting, will always succeed for these.  And if an error is returned, it
triggers the legacy BUG_ON() checks in each routine.

This assumption is wrong, as proven by syzbot: the buffer layer called by
nilfs_prepare_chunk() may call nilfs_get_block() if necessary, which may
fail due to metadata corruption or other reasons.  This has been there all
along, but improved sanity checks and error handling may have made it more
reproducible in fuzzing tests.

Fix this issue by adding missing error paths in nilfs_set_link(),
nilfs_delete_entry(), and their caller nilfs_rename().

Link: https://lkml.kernel.org/r/20250111143518.7901-1-konishi.ryusuke@gmail.com
Link: https://lkml.kernel.org/r/20250111143518.7901-2-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+32c3706ebf5d95046ea1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=32c3706ebf5d95046ea1
Reported-by: syzbot+1097e95f134f37d9395c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1097e95f134f37d9395c
Fixes: 2ba466d74e ("nilfs2: directory entry operations")
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-03-13 12:53:25 +01:00
..
alloc.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-11 12:47:19 +02:00
alloc.h nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-11 12:47:19 +02:00
bmap.c
bmap.h
btnode.c nilfs2: fix buffer head leaks in calls to truncate_inode_pages() 2024-12-27 13:53:00 +01:00
btnode.h
btree.c nilfs2: fix potential oob read in nilfs_btree_check_delete() 2024-10-17 15:21:00 +02:00
btree.h
cpfile.c
cpfile.h
dat.c nilfs2: prevent WARNING in nilfs_dat_commit_end() 2024-08-29 17:30:16 +02:00
dat.h
dir.c nilfs2: handle errors that nilfs_prepare_chunk() may return 2025-03-13 12:53:25 +01:00
direct.c nilfs2: initialize "struct nilfs_binfo_dat"->bi_pad field 2024-08-29 17:30:17 +02:00
direct.h
export.h
file.c
gcinode.c nilfs2: fix buffer head leaks in calls to truncate_inode_pages() 2024-12-27 13:53:00 +01:00
ifile.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-11 12:47:19 +02:00
ifile.h
inode.c nilfs2: do not output warnings when clearing dirty buffers 2025-02-21 13:50:10 +01:00
ioctl.c nilfs2: fix out-of-range warning 2024-06-12 11:03:04 +02:00
Kconfig
Makefile
mdt.c nilfs2: do not output warnings when clearing dirty buffers 2025-02-21 13:50:10 +01:00
mdt.h
namei.c nilfs2: handle errors that nilfs_prepare_chunk() may return 2025-03-13 12:53:25 +01:00
nilfs.h nilfs2: handle errors that nilfs_prepare_chunk() may return 2025-03-13 12:53:25 +01:00
page.c nilfs2: do not force clear folio if buffer is referenced 2025-02-21 13:50:10 +01:00
page.h nilfs2: do not output warnings when clearing dirty buffers 2025-02-21 13:50:10 +01:00
recovery.c nilfs2: fix missing cleanup on rollforward recovery error 2024-09-12 11:10:18 +02:00
segbuf.c
segbuf.h
segment.c nilfs2: protect access to buffers with no active references 2025-02-21 13:50:10 +01:00
segment.h
sufile.c
sufile.h
super.c
sysfs.c nilfs2: protect references to superblock parameters exposed in sysfs 2024-09-12 11:10:18 +02:00
sysfs.h
the_nilfs.c nilfs2: fix inode number range checks 2024-07-11 12:47:13 +02:00
the_nilfs.h nilfs2: fix inode number range checks 2024-07-11 12:47:13 +02:00