From: Siddh Raman Pant via Linux-kernel-mentees <linux-kernel-mentees@lists.linuxfoundation.org>
To: "Hillf Danton" <hdanton@sina.com>
Cc: "Fabio M. De Francesco" <fmdefrancesco@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
syzbot+c70d87ac1d001f29a058
<syzbot+c70d87ac1d001f29a058@syzkaller.appspotmail.com>,
David Howells <dhowells@redhat.com>,
linux-security-modules <linux-security-module@vger.kernel.org>,
linux-kernel-mentees
<linux-kernel-mentees@lists.linuxfoundation.org>
Subject: Re: [PATCH v2] kernel/watch_queue: Make pipe NULL while clearing watch_queue
Date: Sun, 24 Jul 2022 11:56:30 +0530 [thread overview]
Message-ID: <1822ee2c605.4a717678627753.351372059135065111@siddh.me> (raw)
In-Reply-To: <20220724052426.2504-1-hdanton@sina.com>
On Sun, 24 Jul 2022 10:54:26 +0530 Hillf Danton <hdanton@sina.com> wrote:
> According to sysbot's report [1], what is proposed fails to fix the
> reported uaf in the scenario below because of no wqueue->lock acquired
> in the post path. Despite of defunct checked, it is checked after taking
> pipe's wait lock - a bit too late.
>
> Hillf
>
> post_one_notification watch_queue_clear
> === ===
> pipe = wqueue->pipe;
> if (!pipe)
> return false;
> spin_lock_bh(&wqueue->lock);
> wqueue->pipe = NULL;
> spin_lock_bh(&wqueue->lock);
>
> pipe is freed
>
> spin_lock_irq(&pipe->rd_wait.lock); // uaf reported
>
> if (wqueue->defunct)
> goto out;
>
> [1] https://lore.kernel.org/lkml/000000000000aa07b205daba6d49@google.com/
>
Before post_one_notification(), in __post_watch_notification(), on line 228
wqueue->lock is acquired (using lock_wqueue()).
The comment on post_one_notification() also tells that it should be called
with wqueue->lock held. So we do acquire the lock in the post path.
The pipe is freed after the execution of watch_queue_clear() in
free_pipe_info().
A side note: Your emails don't seem to pop up on lore's LKML archive. Maybe
check if the email isn't being blocked?
Thanks,
Siddh
_______________________________________________
Linux-kernel-mentees mailing list
Linux-kernel-mentees@lists.linuxfoundation.org
https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
next parent reply other threads:[~2022-07-24 6:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20220724052426.2504-1-hdanton@sina.com>
2022-07-24 6:26 ` Siddh Raman Pant via Linux-kernel-mentees [this message]
2022-07-24 7:19 ` [PATCH v2] kernel/watch_queue: Make pipe NULL while clearing watch_queue Hillf Danton
2022-07-24 7:48 ` Siddh Raman Pant via Linux-kernel-mentees
2022-07-27 14:49 ` David Howells
2022-07-24 4:02 Siddh Raman Pant via Linux-kernel-mentees
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=1822ee2c605.4a717678627753.351372059135065111@siddh.me \
--to=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=code@siddh.me \
--cc=dhowells@redhat.com \
--cc=fmdefrancesco@gmail.com \
--cc=hdanton@sina.com \
--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).