Skip to content

Commit 2caf982

Browse files
isilenceaxboe
authored andcommitted
io_uring: fix ->extra{1,2} misuse
We don't really know the state of req->extra{1,2] fields in __io_fill_cqe_req(), if an opcode handler is not aware of CQE32 option, it never sets them up properly. Track the state of those fields with a request flag. Fixes: 76c68fb ("io_uring: enable CQE32") Signed-off-by: Pavel Begunkov <[email protected]> Link: https://lore.kernel.org/r/4b3e5be512fbf4debec7270fd485b8a3b014d464.1655287457.git.asml.silence@gmail.com Signed-off-by: Jens Axboe <[email protected]>
1 parent 29ede20 commit 2caf982

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

fs/io_uring.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,7 @@ enum {
844844
REQ_F_SINGLE_POLL_BIT,
845845
REQ_F_DOUBLE_POLL_BIT,
846846
REQ_F_PARTIAL_IO_BIT,
847+
REQ_F_CQE32_INIT_BIT,
847848
REQ_F_APOLL_MULTISHOT_BIT,
848849
/* keep async read/write and isreg together and in order */
849850
REQ_F_SUPPORT_NOWAIT_BIT,
@@ -913,6 +914,8 @@ enum {
913914
REQ_F_PARTIAL_IO = BIT(REQ_F_PARTIAL_IO_BIT),
914915
/* fast poll multishot mode */
915916
REQ_F_APOLL_MULTISHOT = BIT(REQ_F_APOLL_MULTISHOT_BIT),
917+
/* ->extra1 and ->extra2 are initialised */
918+
REQ_F_CQE32_INIT = BIT(REQ_F_CQE32_INIT_BIT),
916919
};
917920

918921
struct async_poll {
@@ -2488,8 +2491,12 @@ static inline bool __io_fill_cqe_req(struct io_ring_ctx *ctx,
24882491
req->cqe.res, req->cqe.flags,
24892492
0, 0);
24902493
} else {
2491-
u64 extra1 = req->extra1;
2492-
u64 extra2 = req->extra2;
2494+
u64 extra1 = 0, extra2 = 0;
2495+
2496+
if (req->flags & REQ_F_CQE32_INIT) {
2497+
extra1 = req->extra1;
2498+
extra2 = req->extra2;
2499+
}
24932500

24942501
trace_io_uring_complete(req->ctx, req, req->cqe.user_data,
24952502
req->cqe.res, req->cqe.flags, extra1, extra2);
@@ -5019,6 +5026,7 @@ static inline void io_req_set_cqe32_extra(struct io_kiocb *req,
50195026
{
50205027
req->extra1 = extra1;
50215028
req->extra2 = extra2;
5029+
req->flags |= REQ_F_CQE32_INIT;
50225030
}
50235031

50245032
/*

0 commit comments

Comments
 (0)