Skip to content

Commit 508c131

Browse files
committed
io_uring/futex: ensure io_futex_wait() cleans up properly on failure
The io_futex_data is allocated upfront and assigned to the io_kiocb async_data field, but the request isn't marked with REQ_F_ASYNC_DATA at that point. Those two should always go together, as the flag tells io_uring whether the field is valid or not. Additionally, on failure cleanup, the futex handler frees the data but does not clear ->async_data. Clear the data and the flag in the error path as well. Thanks to Trend Micro Zero Day Initiative and particularly ReDress for reporting this. Cc: stable@vger.kernel.org Fixes: 194bb58 ("io_uring: add support for futex wake and wait") Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9d83e1f commit 508c131

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

io_uring/futex.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags)
288288
goto done_unlock;
289289
}
290290

291+
req->flags |= REQ_F_ASYNC_DATA;
291292
req->async_data = ifd;
292293
ifd->q = futex_q_init;
293294
ifd->q.bitset = iof->futex_mask;
@@ -309,6 +310,8 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags)
309310
if (ret < 0)
310311
req_set_fail(req);
311312
io_req_set_res(req, ret, 0);
313+
req->async_data = NULL;
314+
req->flags &= ~REQ_F_ASYNC_DATA;
312315
kfree(ifd);
313316
return IOU_COMPLETE;
314317
}

0 commit comments

Comments
 (0)