Skip to content

Commit a8cb90f

Browse files
committed
io_uring/sqpoll: don't put task_struct on tctx setup failure
JIRA: https://issues.redhat.com/browse/RHEL-105612 commit f2320f1 Author: Jens Axboe <axboe@kernel.dk> Date: Tue Jun 17 06:43:18 2025 -0600 io_uring/sqpoll: don't put task_struct on tctx setup failure A recent commit moved the error handling of sqpoll thread and tctx failures into the thread itself, as part of fixing an issue. However, it missed that tctx allocation may also fail, and that io_sq_offload_create() does its own error handling for the task_struct in that case. Remove the manual task putting in io_sq_offload_create(), as io_sq_thread() will notice that the tctx did not get setup and hence it should put itself and exit. Reported-by: syzbot+763e12bbf004fb1062e4@syzkaller.appspotmail.com Fixes: ac0b8b3 ("io_uring: fix use-after-free of sq->thread in __io_uring_show_fdinfo()") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
1 parent 6923d5c commit a8cb90f

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

io_uring/sqpoll.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,6 @@ void io_sqpoll_wait_sq(struct io_ring_ctx *ctx)
427427
__cold int io_sq_offload_create(struct io_ring_ctx *ctx,
428428
struct io_uring_params *p)
429429
{
430-
struct task_struct *task_to_put = NULL;
431430
int ret;
432431

433432
/* Retain compatibility with failing for an invalid attach attempt */
@@ -511,7 +510,7 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
511510
rcu_assign_pointer(sqd->thread, tsk);
512511
mutex_unlock(&sqd->lock);
513512

514-
task_to_put = get_task_struct(tsk);
513+
get_task_struct(tsk);
515514
ret = io_uring_alloc_task_context(tsk, ctx);
516515
wake_up_new_task(tsk);
517516
if (ret)
@@ -526,8 +525,6 @@ __cold int io_sq_offload_create(struct io_ring_ctx *ctx,
526525
complete(&ctx->sq_data->exited);
527526
err:
528527
io_sq_thread_finish(ctx);
529-
if (task_to_put)
530-
put_task_struct(task_to_put);
531528
return ret;
532529
}
533530

0 commit comments

Comments
 (0)