Skip to contentSkip to conversation

io_uring/waitid: clear waitid info before copying it to userspace

PATCH Jens Axboe 1 participant 1 message May 16 1 message not in the archive io_uring

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Jens Axboe

author maintainer
#1 lore raw
Quoted 25 lines · 강희찬

IORING_OP_WAITID stores its result fields in struct io_waitid::info and later copies them to userspace siginfo. The prep path initializes the request arguments, but it does not initialize info itself.

If the wait operation completes without reporting a child event, the common wait code can return without writing wo_info. In that case io_waitid_finish() still copies iw->info to userspace, exposing stale bytes from the reused io_kiocb command storage.

Clear the result storage during prep so the io_uring path matches the regular waitid syscall, which uses a zero-initialized struct waitid_info.

Fixes f31ecf671ddc ("io_uring: add IORING_OP_WAITID support")

---
 io_uring/waitid.c | 1 +

 1 file changed, 1 insertion(+)
io_uring/waitid.c +0 -0
index d25d60aed6a..32f68fd7fcd 100644

io_uring/waitid.c int io_waitid_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) · line 280

Quoted 6 lines
io_uring/waitid.c +1 -0
@@ -275,6 +275,7 @@int io_waitid_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
     iw->options = READ_ONCE(sqe->file_index);
     iw->head = NULL;
     iw->infop = u64_to_user_ptr(READ_ONCE(sqe->addr2));
+   memset(&iw->info, 0, sizeof(iw->info));
     return 0;
  }

Patch looks fine, but you can't send html formatted stuff - it won't make it to the list, and it also corrupts the patch so it can't get applied. Send everything plain/text.

Signature · 1 line
Jens Axboe