[PATCH 5.10] io_uring: prevent opcode speculation

Alexey Panov posted 1 patch 22 hours ago
io_uring/io_uring.c | 2 ++
1 file changed, 2 insertions(+)
[PATCH 5.10] io_uring: prevent opcode speculation
Posted by Alexey Panov 22 hours ago
From: Pavel Begunkov <asml.silence@gmail.com>

commit 1e988c3fe1264708f4f92109203ac5b1d65de50b upstream.

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>
[ Alexey: Sanitize req->opcode directly because io_init_req() in
  linux-5.10.y has no local opcode variable and subsequent lookups use it. ]
Signed-off-by: Alexey Panov <apanov@astralinux.ru>
---
Backport fix for CVE-2025-21863
 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 2ca09e2dbd3d..51262d48a4a1 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -7193,6 +7193,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;
 
-- 
2.47.3
Re: [PATCH 5.10] io_uring: prevent opcode speculation
Posted by Sasha Levin 22 minutes ago
On Wed, Jun 10, 2026 at 08:22:03PM +0300, Alexey Panov wrote:
> From: Pavel Begunkov <asml.silence@gmail.com>
>
> commit 1e988c3fe1264708f4f92109203ac5b1d65de50b upstream.
>
> sqe->opcode is used for different tables, make sure we santitise it
> against speculations.

The 5.10 backport itself looks fine, but I can't take it on its own:
1e988c3fe126 is still missing from 6.6.y and 6.12.y (it's present in
7.0, 6.18, 6.1 and 5.15), and we don't add a fix to an older tree while
a newer one is missing it. Once 6.6.y and 6.12.y carry it, I'll queue
the 5.10 backport.

--
Thanks,
Sasha