提交 57d09d7d 编写于 作者: S Sheng Yong 提交者: Xie XiuQi

f2fs: check if file namelen exceeds max value

mainline inclusion
from mainline-v5.1-rc1
commit 720db068
category: bugfix
bugzilla: 13690
CVE: CVE-2019-9445

-------------------------------------------------

Dentry bitmap is not enough to detect incorrect dentries. So this patch
also checks the namelen value of a dentry.
Signed-off-by: NGong Chen <gongchen4@huawei.com>
Signed-off-by: NSheng Yong <shengyong1@huawei.com>
Reviewed-by: NChao Yu <yuchao0@huawei.com>
Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Reviewed-by: NWei Fang <fangwei1@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 7cc2cc9a
...@@ -812,7 +812,8 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d, ...@@ -812,7 +812,8 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
/* check memory boundary before moving forward */ /* check memory boundary before moving forward */
bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len)); bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
if (unlikely(bit_pos > d->max)) { if (unlikely(bit_pos > d->max ||
le16_to_cpu(de->name_len) > F2FS_NAME_LEN)) {
f2fs_msg(sbi->sb, KERN_WARNING, f2fs_msg(sbi->sb, KERN_WARNING,
"%s: corrupted namelen=%d, run fsck to fix.", "%s: corrupted namelen=%d, run fsck to fix.",
__func__, le16_to_cpu(de->name_len)); __func__, le16_to_cpu(de->name_len));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册