Skip to content

Commit 69a62e0

Browse files
committed
io_uring/msg_ring: don't leave potentially dangling ->tctx pointer
For remote posting of messages, req->tctx is assigned even though it is never used. Rather than leave a dangling pointer, just clear it to NULL and use the previous check for a valid submitter_task to gate on whether or not the request should be terminated. Reported-by: Jann Horn <[email protected]> Fixes: b6f58a3 ("io_uring: move struct io_kiocb from task_struct to io_uring_task") Signed-off-by: Jens Axboe <[email protected]>
1 parent 2839ab7 commit 69a62e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

io_uring/msg_ring.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ static void io_msg_tw_complete(struct io_kiocb *req, struct io_tw_state *ts)
8989
static int io_msg_remote_post(struct io_ring_ctx *ctx, struct io_kiocb *req,
9090
int res, u32 cflags, u64 user_data)
9191
{
92-
req->tctx = READ_ONCE(ctx->submitter_task->io_uring);
93-
if (!req->tctx) {
92+
if (!READ_ONCE(ctx->submitter_task)) {
9493
kmem_cache_free(req_cachep, req);
9594
return -EOWNERDEAD;
9695
}
9796
req->cqe.user_data = user_data;
9897
io_req_set_res(req, res, cflags);
9998
percpu_ref_get(&ctx->refs);
10099
req->ctx = ctx;
100+
req->tctx = NULL;
101101
req->io_task_work.func = io_msg_tw_complete;
102102
io_req_task_work_add_remote(req, ctx, IOU_F_TWQ_LAZY_WAKE);
103103
return 0;

0 commit comments

Comments
 (0)