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>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	syzkaller-bugs <syzkaller-bugs@googlegroups.com>,
	syzbot <syzbot+15927486a4f1bfcbaf91@syzkaller.appspotmail.com>
Subject: Re: general protection fault in fanotify_handle_event
Date: Wed, 24 Apr 2019 13:46:02 +0200	[thread overview]
Message-ID: <20190424114602.GA29968@quack2.suse.cz> (raw)
In-Reply-To: <CAOQ4uxj83NA0QYP_kqgyRWxicUuQHoPK+vcTLEN-+rL+Vwa2HQ@mail.gmail.com>

On Tue 23-04-19 21:05:22, Amir Goldstein wrote:
> On Tue, Apr 23, 2019 at 7:27 PM Jan Kara <jack@suse.cz> wrote:
> >
> > On Fri 19-04-19 12:33:02, Amir Goldstein wrote:
> > > On Thu, Apr 18, 2019 at 8:14 PM syzbot
> > > <syzbot+15927486a4f1bfcbaf91@syzkaller.appspotmail.com> wrote:
> > > >
> > > > syzbot has bisected this bug to:
> > > >
> > > > commit 77115225acc67d9ac4b15f04dd138006b9cd1ef2
> > > > Author: Amir Goldstein <amir73il@gmail.com>
> > > > Date:   Thu Jan 10 17:04:37 2019 +0000
> > > >
> > > >      fanotify: cache fsid in fsnotify_mark_connector
> > > >
> > > > bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=1627632d200000
> > > > start commit:   3f018f4a Add linux-next specific files for 20190418
> > > > git tree:       linux-next
> > > > final crash:    https://syzkaller.appspot.com/x/report.txt?x=1527632d200000
> > > > console output: https://syzkaller.appspot.com/x/log.txt?x=1127632d200000
> > > > kernel config:  https://syzkaller.appspot.com/x/.config?x=faa7bdc352fc157e
> > > > dashboard link: https://syzkaller.appspot.com/bug?extid=15927486a4f1bfcbaf91
> > > > syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=155543d3200000
> > > >
> > > > Reported-by: syzbot+15927486a4f1bfcbaf91@syzkaller.appspotmail.com
> > > > Fixes: 77115225acc6 ("fanotify: cache fsid in fsnotify_mark_connector")
> > > >
> >
> 
> [...]
> 
> >
> > I'd prefer if we could make only fully initialized marks visible on
> > connector's list. Just to make things simple in the fast path of handling
> > events. So I'd just set mark->connector before adding mark to connector's
> > list and having smp_wmb() there to force ordering in
> > fsnotify_add_mark_list(). And we should use READ_ONCE() as a counter-part
> > to this in fanotify_get_fsid(). It is somewhat unfortunate that there are
> > three different ways how fsnotify_add_mark_list() can add mark to a list so
> > we may need to either repeat this in three different places or just use
> > some macro magic like:
> >
> > #define fanotify_attach_obj_list(where, mark, conn, head) \
> >         do { \
> >                 mark->connector = conn; \
> >                 smp_wmb(); \
> >                 hlist_add_##where##_rcu(&mark->obj_list, head); \
> >         } while (0)
> >
> > And I would not really worry about fsnotify_put_mark() - if it ever sees
> > mark->connector set, mark really is on the connector's list and
> > fsnotify_put_mark() does the right thing (i.e. locks connector->lock if
> > needed).
> >
> 
> Sounds good to me.
> 
> I was worried about fsnotify_put_mark() NOT seeing mark->connector set
> even though it is on the list (add mark; get lockless ref; remove
> mark; put lockless ref).
> Its subtle, not sure if possible.

Not possible for the cases it matters. fsnotify_put_mark() just decrements
the refcount. If someone is adding mark to the list, he is by definition
holding one reference so racing fsnotify_put_mark() cannot be dropping the
last one and so the result of the check doesn't really matter.

> I am assuming you will be sending the above patch to syzbot for testing.
> If you want me do help with anything please let me know.

OK, I'll write it and send it.

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

  reply	other threads:[~2019-04-24 11:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-18 17:06 general protection fault in fanotify_handle_event syzbot
2019-04-18 17:14 ` syzbot
2019-04-19  9:33   ` Amir Goldstein
2019-04-23 16:27     ` Jan Kara
2019-04-23 18:05       ` Amir Goldstein
2019-04-24 11:46         ` Jan Kara [this message]
2019-04-26 10:55   ` Jan Kara
2019-04-26 11:13     ` syzbot
2019-04-29  2:10       ` Jan Kara
2019-04-29  5:36         ` syzbot

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=20190424114602.GA29968@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=amir73il@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+15927486a4f1bfcbaf91@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.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;
as well as URLs for NNTP newsgroup(s).