From: Eric Biggers <ebiggers@kernel.org>
To: Siddh Raman Pant <code@siddh.me>
Cc: David Howells <dhowells@redhat.com>,
Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
Eric Dumazet <edumazet@google.com>,
"Fabio M. De Francesco" <fmdefrancesco@gmail.com>,
linux-security-modules <linux-security-module@vger.kernel.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
linux-kernel-mentees
<linux-kernel-mentees@lists.linuxfoundation.org>,
syzbot+c70d87ac1d001f29a058
<syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.com>
Subject: Re: [PATCH v3] kernel/watch_queue: Make pipe NULL while clearing watch_queue
Date: Wed, 3 Aug 2022 18:15:31 +0000 [thread overview]
Message-ID: <Yuq7Q//SH/HjLsxH@gmail.com> (raw)
In-Reply-To: <18262dcb20e.4bf31faa421018.1228982721921458740@siddh.me>
On Wed, Aug 03, 2022 at 02:10:06PM +0530, Siddh Raman Pant wrote:
> On Wed, 03 Aug 2022 11:11:31 +0530 Eric Biggers <ebiggers@kernel.org> wrote:
> > I tested the syzbot reproducer
> > https://syzkaller.appspot.com/text?tag=ReproC&x=174ea97e080000, and it does
> > *not* trigger the bug on the latest upstream. But, it does trigger the bug if I
> > recent Linus's recent watch_queue fixes.
> >
> > So I don't currently see any evidence of an unfixed bug. If, nevertheless, you
> > believe that a bug is still unfixed, then please provide a reproducer and a fix
> > patch that clearly explains what it is fixing.
> >
> > > There is a null check in post_one_notification for the pipe, most probably
> > > because it *expects* the pointer to be NULL'd. Also, there is no reason to have
> > > a dangling pointer stay, it's just a recipe for further bugs.
> >
> > If you want to send a patch or patches to clean up the code, that is fine, but
> > please make it super clear what is a cleanup and what is a fix.
> >
> > - Eric
> >
>
> I honestly feel like I am repeating myself yet again, but okay.
Well, you should try listening instead. Because you are not listening.
> Of course, the race condition has been solved by a patch upstream, which I had
> myself mentioned earlier.
>
> But what I am saying is that it did *not* address *what* that race condition
> had triggered, i.e. the visible cause of the UAF crash, which, among other
> things, is *because* there is a dangling pointer to the freed pipe, which
> *caused* the crash in post_one_notification() when it tried to access
> &pipe->rd.wait_lock as an argument to spin_lock_irq(), a path it reached
> after checking if wqueue->pipe is NULL and proceeded when it was not the case.
>
> And the upstream commit was made *after* I had posted this patch, hence this
> was a fix for the syzkaller issue. While I am *not* saying to accept it just
> because this was posted earlier, I am saying this patch addresses a parallel
> issue, i.e. the *actual use-after-free crash* which was reproduced by those
> reproducers, i.e., what was attempted to be used after getting freed and
> detected by KASAN.
Even if wqueue->pipe was set to NULL during free_pipe_info(), there would still
have been a use-after-free, as the real bug was the lack of synchronization
between post_one_notification() and free_pipe_info(). That is fixed now.
>
> We don't need to wait for another similar syzbot report to pop up before doing
> this change, and say let's not fix a dangling pointer reference because now
> another commit apparately fixes the specific syzkaller issue, causing the given
> specific reproducer with its specific way of reproducing to fail, when we in
> fact now know it *can* be a valid problem in practice and doing this change
> too causes the specific reproducer under consideration to fail reproducing, as
> was reported by the reproducer itself.
To re-iterate, I encourage you to send a cleanup patch if you see an
opportunity. It looks like the state wqueue->defunct==true could be replaced
with wqueue->pipe==NULL, which would be simpler, so how about doing that? Just
don't claim that it is "fixing" something, unless it is, as that makes things
very confusing and difficult for everyone.
>
> I really don't know how to create stress tests / reproducers like how syzkaller
> makes, so if a similar new reproducer is really required for showing this
> patch's validity disregarding any earlier reproducers, I unfortunately cannot
> make it due to skill issue as I just started in kernel dev, and I am deeply
> sorry for wasting the time of everyone, and I am thankful for your criticism of
> my patch.
A reproducer can just be written as a normal program, in C or another language.
The syzkaller reproducers are really hard to read as they are auto-generated, so
don't read too much into them -- they're certainly not examples of good code.
- Eric
next prev parent reply other threads:[~2022-08-03 18:17 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-28 15:51 [PATCH v3] kernel/watch_queue: Make pipe NULL while clearing watch_queue Siddh Raman Pant
2022-08-01 9:34 ` Siddh Raman Pant
2022-08-01 10:24 ` Greg KH
2022-08-01 12:58 ` Siddh Raman Pant
2022-08-01 13:00 ` Siddh Raman Pant
2022-08-01 16:16 ` Dipanjan Das
2022-08-01 18:49 ` Siddh Raman Pant
2022-08-03 1:16 ` Eric Biggers
2022-08-03 3:58 ` Siddh Raman Pant
2022-08-03 4:10 ` Dipanjan Das
2022-08-03 1:08 ` Eric Biggers
2022-08-03 3:56 ` Siddh Raman Pant
2022-08-03 4:12 ` Eric Biggers
2022-08-03 5:13 ` Siddh Raman Pant
2022-08-03 5:41 ` Eric Biggers
2022-08-03 8:40 ` Siddh Raman Pant
2022-08-03 18:15 ` Eric Biggers [this message]
2022-08-04 8:39 ` Siddh Raman Pant
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=Yuq7Q//SH/HjLsxH@gmail.com \
--to=ebiggers@kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=code@siddh.me \
--cc=dhowells@redhat.com \
--cc=edumazet@google.com \
--cc=fmdefrancesco@gmail.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.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).