From: Jaegeuk Kim <jaegeuk@kernel.org>
To: Sheng Yong <shengyong1@huawei.com>
Cc: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net,
"gongchen (E)" <gongchen4@huawei.com>
Subject: Re: [f2fs-dev] [PATCH] f2fs: check memory boundary by insane namelen
Date: Mon, 26 Nov 2018 15:25:29 -0800 [thread overview]
Message-ID: <20181126232529.GC55960@jaegeuk-macbookpro.roam.corp.google.com> (raw)
In-Reply-To: <3d213d40-a4b0-6e60-87b2-81e66866ac4c@huawei.com>
On 11/23, Sheng Yong wrote:
> Hi, Jaegeuk and Chao,
>
> On 2018/11/15 15:50, Jaegeuk Kim wrote:
> > If namelen is corrupted to have very long value, fill_dentries can copy
> > wrong memory area.
> >
> Is there any scenario that could hit this corruption? Or this is triggered
> by fuzzing injection?
Hi Sheng,
It's from a fuzzing test.
Thanks,
>
> thanks,
> Sheng Yong
>
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> > fs/f2fs/dir.c | 12 +++++++++++-
> > 1 file changed, 11 insertions(+), 1 deletion(-)
> >
> > diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
> > index bacc667950b6..c0c845da12fa 100644
> > --- a/fs/f2fs/dir.c
> > +++ b/fs/f2fs/dir.c
> > @@ -808,6 +808,17 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
> > de_name.name = d->filename[bit_pos];
> > de_name.len = le16_to_cpu(de->name_len);
> > + /* check memory boundary before moving forward */
> > + bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
> > + if (unlikely(bit_pos > d->max)) {
> > + f2fs_msg(sbi->sb, KERN_WARNING,
> > + "%s: corrupted namelen=%d, run fsck to fix.",
> > + __func__, le16_to_cpu(de->name_len));
> > + set_sbi_flag(sbi, SBI_NEED_FSCK);
> > + err = -EINVAL;
> > + goto out;
> > + }
> > +
> > if (f2fs_encrypted_inode(d->inode)) {
> > int save_len = fstr->len;
> > @@ -830,7 +841,6 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
> > if (readdir_ra)
> > f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
> > - bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
> > ctx->pos = start_pos + bit_pos;
> > }
> > out:
> >
prev parent reply other threads:[~2018-11-26 23:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 7:50 Jaegeuk Kim
2018-11-17 2:27 ` [f2fs-dev] " Chao Yu
2018-11-23 12:11 ` Sheng Yong
2018-11-24 9:59 ` Chao Yu
2018-11-26 23:25 ` Jaegeuk Kim [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181126232529.GC55960@jaegeuk-macbookpro.roam.corp.google.com \
--to=jaegeuk@kernel.org \
--cc=gongchen4@huawei.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=shengyong1@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®