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

f2fs: check if file namelen exceeds max value

Dentry bitmap is not enough to detect incorrect dentries. So this patch
also checks the namelen value of a dentry.

Signed-off-by: Gong Chen <gongchen4@huawei.com>
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Sheng Yong and committed by
Jaegeuk Kim
720db068 ddf06b75

+2 -1
+2 -1
fs/f2fs/dir.c
··· 814 814 815 815 /* check memory boundary before moving forward */ 816 816 bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); 817 - if (unlikely(bit_pos > d->max)) { 817 + if (unlikely(bit_pos > d->max || 818 + le16_to_cpu(de->name_len) > F2FS_NAME_LEN)) { 818 819 f2fs_msg(sbi->sb, KERN_WARNING, 819 820 "%s: corrupted namelen=%d, run fsck to fix.", 820 821 __func__, le16_to_cpu(de->name_len));