]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
f2fs: Add sanity checks before unlinking and loading inodes
authorNikola Z. Ivanov <zlatistiv@gmail.com>
Wed, 5 Nov 2025 11:09:43 +0000 (13:09 +0200)
committerJaegeuk Kim <jaegeuk@kernel.org>
Thu, 4 Dec 2025 02:00:03 +0000 (02:00 +0000)
commitf37981edcd06cd552c15c153c3202a6b2fa450e4
tree083a87bd73d84f052ce2c1731fc50da411401831
parent9b3c8336c633ca11778a1ff42b7c37b0563e6430
f2fs: Add sanity checks before unlinking and loading inodes

Add check for inode->i_nlink == 1 for directories during unlink,
as their value is decremented twice, which can trigger a warning in
drop_nlink. In such case mark the filesystem as corrupted and return
from the function call with the relevant failure return value.

Additionally add the check for i_nlink == 1 in
sanity_check_inode in order to detect on-disk corruption early.

Reported-by: syzbot+c07d47c7bc68f47b9083@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=c07d47c7bc68f47b9083
Tested-by: syzbot+c07d47c7bc68f47b9083@syzkaller.appspotmail.com
Signed-off-by: Nikola Z. Ivanov <zlatistiv@gmail.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/inode.c
fs/f2fs/namei.c