Skip to contentSkip to conversation

io_uring/io-wq: save worker type before dropping its reference

PATCH In review Alexander Martyniuk 2 participants 2 messages Nov 24 Stable branch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring/io-wq: save worker type before dropping its reference

From: Kyle Zeng <[email protected]>

commit 37e425460b7c41687e51e3254b1eb1d799da9614 upstream.

io_wq_cancel_tw_create() inspects cb->func after calling io_worker_cancel_cb(). For an existing worker, that call can drop the last worker reference and wake io_worker_exit(). If the canceling task is preempted, the worker can be unlinked and freed by kfree_rcu() before the callback function is inspected. KASAN reports a slab-use-after-free read in this path.

Save whether the callback belongs to an unpublished continuation worker while its reference is still held, then use the saved result for the conditional free. This preserves the existing accounting and frees only the worker allocated for the canceled continuation.

Fixes e6db6f9398da ("io_uring/io-wq: only free worker if it was allocated for creation")

---
Backport fix for CVE-2026-99804

 io_uring/io-wq.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
io_uring/io-wq.c +5 -3
index f57743d911b4..2692f5ef387f 100644
@@ -1232,14 +1232,16 @@ static void io_wq_cancel_tw_create(struct io_wq *wq)
 
 	while ((cb = task_work_cancel_match(wq->task, io_task_work_match, wq)) != NULL) {
 		struct io_worker *worker;
+		bool free_worker;
 
 		worker = container_of(cb, struct io_worker, create_work);
-		io_worker_cancel_cb(worker);
 		/*
 		 * Only the worker continuation helper has worker allocated and
-		 * hence needs freeing.
+		 * hence needs freeing. Save this before dropping its reference.
 		 */
-		if (cb->func == create_worker_cont)
+		free_worker = cb->func == create_worker_cont;
+		io_worker_cancel_cb(worker);
+		if (free_worker)
 			kfree(worker);
 	}
 }
Signature · 1 line
2.43.0
#1 lore raw
Quoted 3 lines · Alexander Martyniuk

From: Kyle Zeng <[email protected]>

commit 37e425460b7c41687e51e3254b1eb1d799da9614 upstream.

Not sure why you're sending this, it's already in stable?

Signature · 1 line
Jens Axboe