From 18eae8420081ef8e043ad455937bfb470ef08607 Mon Sep 17 00:00:00 2001 From: Pavel Begunkov Date: Wed, 20 May 2026 14:28:33 +0800 Subject: [PATCH] io_uring: prevent opcode speculation [ Upstream commit 1e988c3fe1264708f4f92109203ac5b1d65de50b ] sqe->opcode is used for different tables, make sure we santitise it against speculations. Cc: stable@vger.kernel.org Fixes: d3656344fea03 ("io_uring: add lookup table for various opcode needs") Signed-off-by: Pavel Begunkov Reviewed-by: Li Zetao Link: https://lore.kernel.org/r/7eddbf31c8ca0a3947f8ed98271acc2b4349c016.1739568408.git.asml.silence@gmail.com Signed-off-by: Jens Axboe [ Use req->opcode instead of opcode here. ] Signed-off-by: Robert Garcia Signed-off-by: Sasha Levin --- io_uring/io_uring.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index cb54ebda0a8a..8ecf01f1b689 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -7366,6 +7366,8 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, return -EINVAL; if (unlikely(req->opcode >= IORING_OP_LAST)) return -EINVAL; + req->opcode = array_index_nospec(req->opcode, IORING_OP_LAST); + if (!io_check_restriction(ctx, req, sqe_flags)) return -EACCES;