io_uring: flush deferred completions in io_req_post_cqe32()
PATCH 1/1 io_uring: flush deferred completions in io_req_post_cqe32()
io_req_post_cqe32() is missing the deferred completion flush that its sibling io_req_post_cqe() has. Without flushing pending deferred completions before posting a 32-byte CQE, multishot CQEs can be delivered to userspace out of order.
Add the same flush check that io_req_post_cqe() performs.
Signed-off-by Josh Law <[email protected]>
--- io_uring/io_uring.c | 8 ++++++++ 1 file changed, 8 insertions(+)
io_uring/io_uring.c +8 -0
@@ -881,6 +881,14 @@ bool io_req_post_cqe32(struct io_kiocb *req, struct io_uring_cqe cqe[2])struct io_ring_ctx *ctx = req->ctx;bool posted; +/* +* If multishot has already posted deferred completions, ensure that +* those are flushed first before posting this one. If not, CQEs +* could get reordered. +*/ +if (!wq_list_empty (&ctx->submit_state.compl_reqs)) +__io_submit_flush_completions (ctx); +lockdep_assert (!io_wq_current_is_worker ());lockdep_assert_held (&ctx->uring_lock);
Signature · 1 line
2.34.1