Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 5.15.y] io_uring: prevent opcode speculation
@ 2026-05-20  6:28 Robert Garcia
  2026-05-20 14:31 ` Sasha Levin
  0 siblings, 1 reply; 2+ messages in thread
From: Robert Garcia @ 2026-05-20  6:28 UTC (permalink / raw)
  To: stable, Pavel Begunkov
  Cc: Jens Axboe, Li Zetao, Robert Garcia, io-uring, linux-kernel

From: Pavel Begunkov <asml.silence@gmail.com>

[ 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 <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>
[ Use req->opcode instead of opcode here. ]
Signed-off-by: Robert Garcia <rob_garcia@163.com>
---
 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 38decfc1a914..47221d7bad61 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -7365,6 +7365,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.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 5.15.y] io_uring: prevent opcode speculation
  2026-05-20  6:28 [PATCH 5.15.y] io_uring: prevent opcode speculation Robert Garcia
@ 2026-05-20 14:31 ` Sasha Levin
  0 siblings, 0 replies; 2+ messages in thread
From: Sasha Levin @ 2026-05-20 14:31 UTC (permalink / raw)
  To: stable, Pavel Begunkov
  Cc: Sasha Levin, Jens Axboe, Li Zetao, Robert Garcia, io-uring,
	linux-kernel

> From: Pavel Begunkov <asml.silence@gmail.com>
>
> [ Upstream commit 1e988c3fe1264708f4f92109203ac5b1d65de50b ]
>
> sqe->opcode is used for different tables, make sure we santitise it
> against speculations.
[...]
> [ Use req->opcode instead of opcode here. ]
> Signed-off-by: Robert Garcia <rob_garcia@163.com>

Thanks for the backport. Upstream 1e988c3fe126 is currently queued or
present on 6.6, 6.12, 6.18 and 7.0, but it is missing from both 5.15
and 6.1 - we should not skip 6.1 when backporting a Cc:stable fix to
5.15.

Could you send a matching backport for 6.1 as well? Once we have
coverage from 6.1 onwards I'll queue both together.

--
Thanks,
Sasha

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-05-20 14:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20  6:28 [PATCH 5.15.y] io_uring: prevent opcode speculation Robert Garcia
2026-05-20 14:31 ` Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox