]> www.infradead.org Git - users/willy/xarray.git/commit
nilfs2: fix kernel bug on rename operation of broken directory
authorRyusuke Konishi <konishi.ryusuke@gmail.com>
Fri, 28 Jun 2024 16:51:07 +0000 (01:51 +0900)
committerAndrew Morton <akpm@linux-foundation.org>
Thu, 4 Jul 2024 05:40:38 +0000 (22:40 -0700)
commita9e1ddc09ca55746079cc479aa3eb6411f0d99d4
tree65f18fac9b19781fb3b71ef61190ae46979ff4bf
parentbd225530a4c717714722c3731442b78954c765b3
nilfs2: fix kernel bug on rename operation of broken directory

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: 2ba466d74ed7 ("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>
fs/nilfs2/dir.c