io_uring/uring_cmd: unconditionally copy SQEs at prep time io_uring-6.14-20250214
authorJens Axboe <axboe@kernel.dk>
Thu, 13 Feb 2025 15:24:23 +0000 (08:24 -0700)
committerJens Axboe <axboe@kernel.dk>
Thu, 13 Feb 2025 17:24:39 +0000 (10:24 -0700)
commitd6211ebbdaa541af197b50b8dd8f22642ce0b87f
tree25299b36be5550ea2499c1cae1e8e4afc37537d8
parent2b4fc4cd43f28e9e39179c8702e6ee821258584d
io_uring/uring_cmd: unconditionally copy SQEs at prep time

This isn't generally necessary, but conditions have been observed where
SQE data is accessed from the original SQE after prep has been done and
outside of the initial issue. Opcode prep handlers must ensure that any
SQE related data is stable beyond the prep phase, but uring_cmd is a bit
special in how it handles the SQE which makes it susceptible to reading
stale data. If the application has reused the SQE before the original
completes, then that can lead to data corruption.

Down the line we can relax this again once uring_cmd has been sanitized
a bit, and avoid unnecessarily copying the SQE.

Fixes: 5eff57fa9f3a ("io_uring/uring_cmd: defer SQE copying until it's needed")
Reported-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Caleb Sander Mateos <csander@purestorage.com>
Reviewed-by: Li Zetao <lizetao1@huawei.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/uring_cmd.c