From a43e236fb9aef4528f2bd24095d1f348030f5d9d Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Mon, 11 Nov 2024 18:13:18 +0800 Subject: [PATCH] io_uring/uring_cmd: fix buffer index retrieval Add back buffer index retrieval for IORING_URING_CMD_FIXED. Reported-by: Guangwu Zhang Cc: Jeff Moyer Fixes: b54a14041ee6 ("io_uring/rsrc: add io_rsrc_node_lookup() helper") Signed-off-by: Ming Lei Reviewed-by: Kanchan Joshi Reviewed-by: Anuj Gupta Tested-by: Guangwu Zhang Link: https://lore.kernel.org/r/20241111101318.1387557-1-ming.lei@redhat.com Signed-off-by: Jens Axboe --- io_uring/uring_cmd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index b62965f58f30..e9d99d3ecc34 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -210,8 +210,9 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (ioucmd->flags & IORING_URING_CMD_FIXED) { struct io_ring_ctx *ctx = req->ctx; struct io_rsrc_node *node; + u16 index = READ_ONCE(sqe->buf_index); - node = io_rsrc_node_lookup(&ctx->buf_table, req->buf_index); + node = io_rsrc_node_lookup(&ctx->buf_table, index); if (unlikely(!node)) return -EFAULT; /*