]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
io_uring: propagate array_index_nospec opcode into req->opcode
authorMichael Bommarito <michael.bommarito@gmail.com>
Sun, 17 May 2026 21:30:10 +0000 (17:30 -0400)
committerJens Axboe <axboe@kernel.dk>
Mon, 18 May 2026 14:59:12 +0000 (08:59 -0600)
commitcf18e36455603d65d4745de83e2d1743c54ada47
tree1b4c3c70d772e60402367d0a36c5d9270a457d3b
parent93d93f5f8da791e98159795c6ef683f45bd95d13
io_uring: propagate array_index_nospec opcode into req->opcode

Commit 1e988c3fe126 ("io_uring: prevent opcode speculation") added
array_index_nospec() to io_init_req(), but applied it only to a local
opcode variable. req->opcode is initialized from sqe->opcode before the
bounds check and remains the raw value.

Keep req->opcode as the canonical opcode in io_init_req(): reject
out-of-range values architecturally, then write the array_index_nospec()
result back to req->opcode before any table lookup. This keeps downstream
users of req->opcode from observing the raw user byte on a mispredicted
path.

No functional change: array_index_nospec() is a no-op for opcodes in
[0, IORING_OP_LAST), and out-of-range opcodes are still rejected at the
bounds check above the assignment.

Fixes: 1e988c3fe126 ("io_uring: prevent opcode speculation")
Assisted-by: Claude:claude-opus-4-7
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Link: https://patch.msgid.link/20260517213010.696135-1-michael.bommarito@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c