From: Keith Busch <kbusch@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: Penglei Jiang <superman.xpt@gmail.com>,
io-uring@vger.kernel.org, linux-kernel@vger.kernel.org,
syzbot+531502bbbe51d2f769f4@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] io_uring: fix use-after-free of sq->thread in __io_uring_show_fdinfo()
Date: Tue, 10 Jun 2025 13:12:51 -0600 [thread overview]
Message-ID: <aEiDs5J3Uy3NSK3m@kbusch-mbp> (raw)
In-Reply-To: <48f61e8e-1de6-4737-9e58-145d4599b0c0@kernel.dk>
On Tue, Jun 10, 2025 at 12:56:31PM -0600, Jens Axboe wrote:
> On 6/10/25 12:44 PM, Keith Busch wrote:
> > On Tue, Jun 10, 2025 at 10:18:01AM -0700, Penglei Jiang wrote:
> >> @@ -379,7 +380,8 @@ static int io_sq_thread(void *data)
> >> io_sq_tw(&retry_list, UINT_MAX);
> >>
> >> io_uring_cancel_generic(true, sqd);
> >> - sqd->thread = NULL;
> >> + rcu_assign_pointer(sqd->thread, NULL);
> >
> > I believe this will fail a sparse check without adding the "__rcu" type
> > annotation on the struct's "thread" member.
>
> I think that only happens the other way around, eg accessing them directly
> when marked with __rcu. I could be entirely wrong, though...
I was just looking at rcu_assign_pointer():
#define rcu_assign_pointer(p, v) \
do { \
uintptr_t _r_a_p__v = (uintptr_t)(v); \
rcu_check_sparse(p, __rcu); \
And rcu_check_sparse expands to this when __CHECKER__ is enabled:
#define rcu_check_sparse(p, space) \
((void)(((typeof(*p) space *)p) == p))
So whatever "p" is, rcu_assign_pointer's checker appears to want it to
be of a type annotated with "__rcu".
But I don't know for sure, so let's just try it and see!
# make C=1 io_uring/sqpoll.o
io_uring/sqpoll.c:273:17: error: incompatible types in comparison expression (different address spaces):
io_uring/sqpoll.c:273:17: struct task_struct [noderef] __rcu *
io_uring/sqpoll.c:273:17: struct task_struct *
io_uring/sqpoll.c:383:9: error: incompatible types in comparison expression (different address spaces):
io_uring/sqpoll.c:383:9: struct task_struct [noderef] __rcu *
io_uring/sqpoll.c:383:9: struct task_struct *
next prev parent reply other threads:[~2025-06-10 19:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 17:18 [PATCH v2] io_uring: fix use-after-free of sq->thread in __io_uring_show_fdinfo() Penglei Jiang
2025-06-10 17:23 ` Jens Axboe
2025-06-10 18:44 ` Keith Busch
2025-06-10 18:56 ` Jens Axboe
2025-06-10 19:12 ` Keith Busch [this message]
2025-06-10 19:15 ` Jens Axboe
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=aEiDs5J3Uy3NSK3m@kbusch-mbp \
--to=kbusch@kernel.org \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=superman.xpt@gmail.com \
--cc=syzbot+531502bbbe51d2f769f4@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