linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Amir Goldstein <amir73il@gmail.com>
Cc: Jan Kara <jack@suse.cz>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Subject: Re: Fw: WARNING: bad usercopy in fanotify_read
Date: Tue, 12 Mar 2019 17:35:43 +0100	[thread overview]
Message-ID: <20190312163543.GD32521@quack2.suse.cz> (raw)
In-Reply-To: <CAOQ4uxjK3aTh7jgib28p7Nbx0gZYTe0YG6s4Aw=OcQa51OZ-eQ@mail.gmail.com>

On Tue 12-03-19 14:59:27, Amir Goldstein wrote:
> On Tue, Mar 12, 2019 at 1:45 PM Jan Kara <jack@suse.cz> wrote:
> >
> > Thanks for forwarding Andrew!
> >
> > On Mon 11-03-19 16:30:04, Andrew Morton wrote:
> > > fyi
> > >
> > > Begin forwarded message:
> > >
> > > Date: Mon, 11 Mar 2019 13:42:06 -0700
> > > From: syzbot <syzbot+2c49971e251e36216d1f@syzkaller.appspotmail.com>
> > > To: akpm@linux-foundation.org, cai@lca.pw, crecklin@redhat.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, syzkaller-bugs@googlegroups.com
> > > Subject: WARNING: bad usercopy in fanotify_read
> > >
> > >
> > > Hello,
> > >
> > > syzbot found the following crash on:
> > >
> > > HEAD commit:    12ad143e Merge branch 'perf-urgent-for-linus' of git://git..
> > > git tree:       upstream
> > > console output: https://syzkaller.appspot.com/x/log.txt?x=12776f57200000
> > > kernel config:  https://syzkaller.appspot.com/x/.config?x=e9d91b7192a5e96e
> > > dashboard link: https://syzkaller.appspot.com/bug?extid=2c49971e251e36216d1f
> > > compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
> > > userspace arch: amd64
> > > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=1287516f200000
> > > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=17ee410b200000
> > >
> > > IMPORTANT: if you fix the bug, please add the following tag to the commit:
> > > Reported-by: syzbot+2c49971e251e36216d1f@syzkaller.appspotmail.com
> > >
> > > ------------[ cut here ]------------
> > > Bad or missing usercopy whitelist? Kernel memory exposure attempt detected
> > > from SLAB object 'fanotify_event' (offset 40, size 8)!
> > > WARNING: CPU: 1 PID: 7649 at mm/usercopy.c:78 usercopy_warn+0xeb/0x110
> > > mm/usercopy.c:78
> >
> > Yeah, right. We need to create fanotify_event cache so that copying of
> > fanotify_event.fid.fh to userspace is allowed. Sadly the area is unioned
> > with a possible slab pointer so that won't be protected from leaking but
> > life is not perfect. Amir, something like attached patch?
> 
> I agree. We could do something like this, to first copy the inline fh
> from slab to short stack buf:
> 
> static inline void *fanotify_fid_fh_user(struct fanotify_fid *fid,
>                                     unsigned int fh_len, char *fh_buf)
> {
>         if (fh_len > FANOTIFY_INLINE_FH_LEN)
>                 return fid->ext_fh;
>         memcpy(fh_buf, fid->fh, fh_len);
>         return fh_buf;
> }
> 
> But I don't think we should bother.

OK, pushed my fix to my tree.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

      reply	other threads:[~2019-03-12 16:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20190311163004.68f936ab4119a7e8dd272f59@linux-foundation.org>
2019-03-12 11:45 ` Fw: WARNING: bad usercopy in fanotify_read Jan Kara
2019-03-12 12:59   ` Amir Goldstein
2019-03-12 16:35     ` Jan Kara [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=20190312163543.GD32521@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).