]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
io_uring/tw: serialize ctx->retry_llist with ->uring_lock
authorJens Axboe <axboe@kernel.dk>
Mon, 27 Apr 2026 20:29:02 +0000 (14:29 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 30 Apr 2026 12:57:20 +0000 (06:57 -0600)
commit17666e2d7592c3e85260cafd3950121524acc2c5
tree9e9f1242cc1d8645e0cd5ba522d4689bde3d8680
parentdf8599ee18c0e5fe343ffe0b4c379636b8bb839a
io_uring/tw: serialize ctx->retry_llist with ->uring_lock

The DEFER_TASKRUN local task work paths all run under ctx->uring_lock,
which serializes them with each other and with the rest of the ring's
hot paths. io_move_task_work_from_local() is the exception - it's called
from io_ring_exit_work() on a kworker without holding the lock and from
the iopoll cancelation side right after dropping it.

->work_llist is fine with this, as it's only ever updated via the
expected paths. But the ->retry_llist is updated while runing, and hence
it could potentially race between normal task_work running and the
task-has-exited shutdown path.

Simply grab ->uring_lock while moving the local work to the fallback
list for exit purposes, which nicely serializes it across both the
normal additions and the exit prune path.

Cc: stable@vger.kernel.org
Fixes: f46b9cdb22f7 ("io_uring: limit local tw done")
Reported-by: Robert Femmer <robert.femmer@x41-dsec.de>
Reported-by: Christian Reitter <invd@inhq.net>
Reported-by: Michael Rodler <michael.rodler@x41-dsec.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/tw.c