* [PATCHSET 0/2] Saner ->async_data handling
@ 2025-08-22 13:14 Jens Axboe
2025-08-22 13:14 ` [PATCH 1/2] io_uring/futex: ensure io_futex_wait() cleans up properly on failure Jens Axboe
2025-08-22 13:14 ` [PATCH 2/2] io_uring: clear ->async_data as part of normal init Jens Axboe
0 siblings, 2 replies; 3+ messages in thread
From: Jens Axboe @ 2025-08-22 13:14 UTC (permalink / raw)
To: io-uring
Hi,
Just two minor fixes - one for an issue where futex was handling
->async_data setting and clearing inconsistently wrt REQ_F_ASYNC_DATA,
and then a followup that just ensures that other opcode handlers can't
mess this up.
io_uring/futex.c | 3 +++
io_uring/io_uring.c | 1 +
2 files changed, 4 insertions(+)
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] io_uring/futex: ensure io_futex_wait() cleans up properly on failure
2025-08-22 13:14 [PATCHSET 0/2] Saner ->async_data handling Jens Axboe
@ 2025-08-22 13:14 ` Jens Axboe
2025-08-22 13:14 ` [PATCH 2/2] io_uring: clear ->async_data as part of normal init Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2025-08-22 13:14 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe, stable
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: 194bb58c6090 ("io_uring: add support for futex wake and wait")
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/futex.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/io_uring/futex.c b/io_uring/futex.c
index 692462d50c8c..9113a44984f3 100644
--- a/io_uring/futex.c
+++ b/io_uring/futex.c
@@ -288,6 +288,7 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags)
goto done_unlock;
}
+ req->flags |= REQ_F_ASYNC_DATA;
req->async_data = ifd;
ifd->q = futex_q_init;
ifd->q.bitset = iof->futex_mask;
@@ -309,6 +310,8 @@ int io_futex_wait(struct io_kiocb *req, unsigned int issue_flags)
if (ret < 0)
req_set_fail(req);
io_req_set_res(req, ret, 0);
+ req->async_data = NULL;
+ req->flags &= ~REQ_F_ASYNC_DATA;
kfree(ifd);
return IOU_COMPLETE;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] io_uring: clear ->async_data as part of normal init
2025-08-22 13:14 [PATCHSET 0/2] Saner ->async_data handling Jens Axboe
2025-08-22 13:14 ` [PATCH 1/2] io_uring/futex: ensure io_futex_wait() cleans up properly on failure Jens Axboe
@ 2025-08-22 13:14 ` Jens Axboe
1 sibling, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2025-08-22 13:14 UTC (permalink / raw)
To: io-uring; +Cc: Jens Axboe
Opcode handlers like POLL_ADD will use ->async_data as the pointer for
double poll handling, which is a bit different than the usual case
where it's strictly gated by the REQ_F_ASYNC_DATA flag. Be a bit more
proactive in handling ->async_data, and clear it to NULL as part of
regular init. Init is touching that cacheline anyway, so might as well
clear it.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
---
io_uring/io_uring.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index 4ef69dd58734..93633613a165 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2119,6 +2119,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
req->file = NULL;
req->tctx = current->io_uring;
req->cancel_seq_set = false;
+ req->async_data = NULL;
if (unlikely(opcode >= IORING_OP_LAST)) {
req->opcode = 0;
--
2.50.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-08-22 13:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-22 13:14 [PATCHSET 0/2] Saner ->async_data handling Jens Axboe
2025-08-22 13:14 ` [PATCH 1/2] io_uring/futex: ensure io_futex_wait() cleans up properly on failure Jens Axboe
2025-08-22 13:14 ` [PATCH 2/2] io_uring: clear ->async_data as part of normal init Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).