diff options
| author | Keith Busch <[email protected]> | 2025-06-11 20:53:43 +0000 |
|---|---|---|
| committer | Jens Axboe <[email protected]> | 2025-06-12 14:17:09 +0000 |
| commit | c538f400fae22725580842deb2bef546701b64bd (patch) | |
| tree | 99abc87d444307a7060fd281078a45746cd1f3d3 /io_uring/io_uring.c | |
| parent | io_uring: fix use-after-free of sq->thread in __io_uring_show_fdinfo() (diff) | |
| download | kernel-c538f400fae22725580842deb2bef546701b64bd.tar.gz kernel-c538f400fae22725580842deb2bef546701b64bd.zip | |
io_uring: consistently use rcu semantics with sqpoll thread
The sqpoll thread is dereferenced with rcu read protection in one place,
so it needs to be annotated as an __rcu type, and should consistently
use rcu helpers for access and assignment to make sparse happy.
Since most of the accesses occur under the sqd->lock, we can use
rcu_dereference_protected() without declaring an rcu read section.
Provide a simple helper to get the thread from a locked context.
Fixes: ac0b8b327a5677d ("io_uring: fix use-after-free of sq->thread in __io_uring_show_fdinfo()")
Signed-off-by: Keith Busch <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[axboe: fold in fix for register.c]
Signed-off-by: Jens Axboe <[email protected]>
Diffstat (limited to 'io_uring/io_uring.c')
| -rw-r--r-- | io_uring/io_uring.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index cf759c172083..4e32f808d07d 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -2906,7 +2906,7 @@ static __cold void io_ring_exit_work(struct work_struct *work) struct task_struct *tsk; io_sq_thread_park(sqd); - tsk = sqd->thread; + tsk = sqpoll_task_locked(sqd); if (tsk && tsk->io_uring && tsk->io_uring->io_wq) io_wq_cancel_cb(tsk->io_uring->io_wq, io_cancel_ctx_cb, ctx, true); @@ -3142,7 +3142,7 @@ __cold void io_uring_cancel_generic(bool cancel_all, struct io_sq_data *sqd) s64 inflight; DEFINE_WAIT(wait); - WARN_ON_ONCE(sqd && sqd->thread != current); + WARN_ON_ONCE(sqd && sqpoll_task_locked(sqd) != current); if (!current->io_uring) return; |
