Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: fix to trigger fsck if dirent.name_len is zero

While traversing dirents in f2fs_fill_dentries(), if bitmap is valid,
filename length should not be zero, otherwise, directory structure
consistency could be corrupted, in this case, let's print related
info and set SBI_NEED_FSCK to trigger fsck for repairing.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Chao Yu and committed by
Jaegeuk Kim
ddf06b75 c20e57b3

+4
+4
fs/f2fs/dir.c
··· 800 800 if (de->name_len == 0) { 801 801 bit_pos++; 802 802 ctx->pos = start_pos + bit_pos; 803 + printk_ratelimited( 804 + "%s, invalid namelen(0), ino:%u, run fsck to fix.", 805 + KERN_WARNING, le32_to_cpu(de->ino)); 806 + set_sbi_flag(sbi, SBI_NEED_FSCK); 803 807 continue; 804 808 } 805 809