From: Jens Axboe <axboe@kernel.dk>
To: asaf meizner <asafmeizner@gmail.com>
Cc: io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BUG] io_uring: 13 remaining unprotected ctx->rings accesses after 61a11cf481272
Date: Thu, 9 Apr 2026 05:39:00 -0600 [thread overview]
Message-ID: <32e0991c-f294-43a7-888a-eadd03079a93@kernel.dk> (raw)
In-Reply-To: <CAEshK0=S+19B1LbamBaNOKTQyw+98QFBjHs04sByu_JL2QOBAw@mail.gmail.com>
On 4/9/26 3:14 AM, asaf meizner wrote:
> Hi Jens,
>
> Commit 61a11cf481272 ("io_uring: protect remaining lockless ctx->rings
> accesses with RCU") introduced RCU protection for ctx->rings during
> ring resize, but at least 13 dereferences were not converted. The
> most concerning is fdinfo.c:63 which reads ctx->rings with no lock
> and no RCU protection at all.
>
> Unprotected accesses found:
>
> io_uring/fdinfo.c:63
> struct io_rings *r = ctx->rings;
> (no lock, no RCU ? TOCTOU with concurrent resize)
>
> io_uring/tw.c:41, 253, 291, 326
> atomic_andnot/atomic_or on ctx->rings->sq_flags
> (lines 249-253 have a comment justifying no RCU for
> !DEFER_TASKRUN, but lines 41 and 291 have no such comment
> and appear to be in contexts where resize could race)
>
> io_uring/sqpoll.c:380, 407, 421
> atomic_or/atomic_andnot on ctx->rings->sq_flags
> (under sqd->lock, but resize takes uring_lock ? different locks)
>
> io_uring/io_uring.c:574, 647, 690, 1985, 1986
> CQ overflow flags and sq_dropped counter
>
> The fdinfo case is the clearest bug: a read of
> /proc/<pid>/fdinfo/<fd> concurrent with
> IORING_REGISTER_RESIZE_RINGS can dereference a stale ctx->rings
> pointer after the old rings are freed via RCU. This is a UAF read
> that could leak kernel heap data.
The "clearest bug" isn't a bug at all. What you are seemingly missing
here is that rings can't go away if inside ->uring_lock OR
->completion_lock, which is actually documented in io_get_rings().
> The sqpoll case is also concerning because sqd->lock and uring_lock
> are different locks, so the SQPOLL thread can see a stale pointer
> during resize.
And you are also missing that ring resizing isn't supported for SQPOLL,
it's a DEFER_TASKRUN only feature.
--
Jens Axboe
prev parent reply other threads:[~2026-04-09 11:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-09 9:14 asaf meizner
2026-04-09 11:39 ` Jens Axboe [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=32e0991c-f294-43a7-888a-eadd03079a93@kernel.dk \
--to=axboe@kernel.dk \
--cc=asafmeizner@gmail.com \
--cc=io-uring@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®