]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring: prevent opcode speculation
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 14 Feb 2025 22:48:15 +0000 (22:48 +0000)
committerJens Axboe <axboe@kernel.dk>
Sat, 15 Feb 2025 15:15:12 +0000 (08:15 -0700)
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 <asml.silence@gmail.com>
Reviewed-by: Li Zetao <lizetao1@huawei.com>
Link: https://lore.kernel.org/r/7eddbf31c8ca0a3947f8ed98271acc2b4349c016.1739568408.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index 263e504be4a8be4d0ae8f604e279b2cefc49dca8..29a42365a4816ebfcf9036792e33e5d951e396ff 100644 (file)
@@ -2045,6 +2045,8 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
                req->opcode = 0;
                return io_init_fail_req(req, -EINVAL);
        }
+       opcode = array_index_nospec(opcode, IORING_OP_LAST);
+
        def = &io_issue_defs[opcode];
        if (unlikely(sqe_flags & ~SQE_COMMON_FLAGS)) {
                /* enforce forwards compatibility on users */