io_uring: fix cancellation overwriting req->flags
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 14 Jun 2024 00:04:29 +0000 (01:04 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 14 Jun 2024 01:25:28 +0000 (19:25 -0600)
commitf4a1254f2a076afb0edd473589bf40f9b4d36b41
treef7dad023967cad2f50d120ab55aca57cf4a59689
parent54559642b96116b45e4b5ca7fd9f7835b8561272
io_uring: fix cancellation overwriting req->flags

Only the current owner of a request is allowed to write into req->flags.
Hence, the cancellation path should never touch it. Add a new field
instead of the flag, move it into the 3rd cache line because it should
always be initialised. poll_refs can move further as polling is an
involved process anyway.

It's a minimal patch, in the future we can and should find a better
place for it and remove now unused REQ_F_CANCEL_SEQ.

Fixes: 521223d7c229f ("io_uring/cancel: don't default to setting req->work.cancel_seq")
Cc: stable@vger.kernel.org
Reported-by: Li Shi <sl1589472800@gmail.com>
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Link: https://lore.kernel.org/r/6827b129f8f0ad76fa9d1f0a773de938b240ffab.1718323430.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h
io_uring/cancel.h
io_uring/io_uring.c