]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
io_uring: ensure ctx->rings is stable for task work flags manipulation
authorJens Axboe <axboe@kernel.dk>
Mon, 9 Mar 2026 20:21:37 +0000 (14:21 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 11 Mar 2026 20:35:16 +0000 (14:35 -0600)
commit96189080265e6bb5dde3a4afbaf947af493e3f82
tree9b2bea89a60857d5b2de2081ccf0d41561348654
parent785d4625d3e05bb0ac536ff4fd74d096cfe51714
io_uring: ensure ctx->rings is stable for task work flags manipulation

If DEFER_TASKRUN | SETUP_TASKRUN is used and task work is added while
the ring is being resized, it's possible for the OR'ing of
IORING_SQ_TASKRUN to happen in the small window of swapping into the
new rings and the old rings being freed.

Prevent this by adding a 2nd ->rings pointer, ->rings_rcu, which is
protected by RCU. The task work flags manipulation is inside RCU
already, and if the resize ring freeing is done post an RCU synchronize,
then there's no need to add locking to the fast path of task work
additions.

Note: this is only done for DEFER_TASKRUN, as that's the only setup mode
that supports ring resizing. If this ever changes, then they too need to
use the io_ctx_mark_taskrun() helper.

Link: https://lore.kernel.org/io-uring/20260309062759.482210-1-naup96721@gmail.com/
Cc: stable@vger.kernel.org
Fixes: 79cfe9e59c2a ("io_uring/register: add IORING_REGISTER_RESIZE_RINGS")
Reported-by: Hao-Yu Yang <naup96721@gmail.com>
Suggested-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h
io_uring/io_uring.c
io_uring/register.c
io_uring/tw.c