Skip to contentSkip to conversation

aio-posix: zero out io_uring sqe user_data

PATCH Applied Stefan Hajnoczi 1 participant 2 messages Apr 26, 2023 – Aug 24, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 aio-posix: zero out io_uring sqe user_data

liburing does not clear sqe->user_data. We must do it ourselves to avoid undefined behavior in process_cqe() when user_data is used.

Note that fdmon-io_uring is currently disabled, so this is a latent bug that does not affect users. Let's merge this fix now to make it easier to enable fdmon-io_uring in the future (and I'm working on that).

---
 util/fdmon-io_uring.c | 2 ++
 1 file changed, 2 insertions(+)
util/fdmon-io_uring.c +2 -0
index ab43052dd7..35165bcb46 100644
@@ -184,6 +184,7 @@ static void add_poll_remove_sqe(AioContext *ctx, AioHandler *node)
 #else
     io_uring_prep_poll_remove(sqe, node);
 #endif
+    io_uring_sqe_set_data(sqe, NULL);
 }
 
 /* Add a timeout that self-cancels when another cqe becomes ready */
@@ -197,6 +198,7 @@ static void add_timeout_sqe(AioContext *ctx, int64_t ns)
 
     sqe = get_sqe(ctx);
     io_uring_prep_timeout(sqe, &ts, 1, 0);
+    io_uring_sqe_set_data(sqe, NULL);
 }
 
 /* Add sqes from ctx->submit_list for submission */
Signature · 1 line
2.40.0
author Applied
#1 lore raw
Quoted 11 lines · Stefan Hajnoczi

liburing does not clear sqe->user_data. We must do it ourselves to avoid undefined behavior in process_cqe() when user_data is used.

Note that fdmon-io_uring is currently disabled, so this is a latent bug that does not affect users. Let's merge this fix now to make it easier to enable fdmon-io_uring in the future (and I'm working on that).

---
 util/fdmon-io_uring.c | 2 ++
 1 file changed, 2 insertions(+)

Thanks, applied to my block-next tree:
https://gitlab.com/stefanha/qemu/commits/block-next

Stefan