Skip to content

Commit de75a3d

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't leak creds on SQO attach error
Attaching to already dead/dying SQPOLL task is disallowed in io_sq_offload_create(), but cleanup is hand coded by calling io_put_sq_data()/etc., that miss to put ctx->sq_creds. Defer everything to error-path io_sq_thread_finish(), adding ctx->sqd_list in the error case as well as finish will handle it. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent ee53fb2 commit de75a3d

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

fs/io_uring.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7910,22 +7910,17 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
79107910

79117911
ret = 0;
79127912
io_sq_thread_park(sqd);
7913+
list_add(&ctx->sqd_list, &sqd->ctx_list);
7914+
io_sqd_update_thread_idle(sqd);
79137915
/* don't attach to a dying SQPOLL thread, would be racy */
7914-
if (attached && !sqd->thread) {
7916+
if (attached && !sqd->thread)
79157917
ret = -ENXIO;
7916-
} else {
7917-
list_add(&ctx->sqd_list, &sqd->ctx_list);
7918-
io_sqd_update_thread_idle(sqd);
7919-
}
79207918
io_sq_thread_unpark(sqd);
79217919

7922-
if (ret < 0) {
7923-
io_put_sq_data(sqd);
7924-
ctx->sq_data = NULL;
7925-
return ret;
7926-
} else if (attached) {
7920+
if (ret < 0)
7921+
goto err;
7922+
if (attached)
79277923
return 0;
7928-
}
79297924

79307925
if (p->flags & IORING_SETUP_SQ_AFF) {
79317926
int cpu = p->sq_thread_cpu;

0 commit comments

Comments
 (0)