WSL2-Linux-Kernel/fs/nilfs2
Ryusuke Konishi 7000b438dd nilfs2: fix kernel bug on rename operation of broken directory
commit a9e1ddc09ca55746079cc479aa3eb6411f0d99d4 upstream.

Syzbot reported that in rename directory operation on broken directory on
nilfs2, __block_write_begin_int() called to prepare block write may fail
BUG_ON check for access exceeding the folio/page size.

This is because nilfs_dotdot(), which gets parent directory reference
entry ("..") of the directory to be moved or renamed, does not check
consistency enough, and may return location exceeding folio/page size for
broken directories.

Fix this issue by checking required directory entries ("." and "..") in
the first chunk of the directory in nilfs_dotdot().

Link: https://lkml.kernel.org/r/20240628165107.9006-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+d3abed1ad3d367fa2627@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=d3abed1ad3d367fa2627
Fixes: 2ba466d74e ("nilfs2: directory entry operations")
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-07-18 13:07:43 +02:00
..
Kconfig
Makefile
alloc.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
alloc.h nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
bmap.c
bmap.h
btnode.c
btnode.h
btree.c
btree.h
cpfile.c
cpfile.h
dat.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
dat.h
dir.c nilfs2: fix kernel bug on rename operation of broken directory 2024-07-18 13:07:43 +02:00
direct.c
direct.h
export.h
file.c
gcinode.c
ifile.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
ifile.h
inode.c
ioctl.c nilfs2: fix out-of-range warning 2024-06-16 13:39:16 +02:00
mdt.c
mdt.h
namei.c
nilfs.h nilfs2: add missing check for inode numbers on directory entries 2024-07-18 13:07:32 +02:00
page.c
page.h
recovery.c
segbuf.c
segbuf.h
segment.c nilfs2: fix potential kernel bug due to lack of writeback flag waiting 2024-07-05 09:14:22 +02:00
segment.h
sufile.c
sufile.h
super.c
sysfs.c
sysfs.h
the_nilfs.c nilfs2: fix inode number range checks 2024-07-18 13:07:32 +02:00
the_nilfs.h nilfs2: fix inode number range checks 2024-07-18 13:07:32 +02:00