summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-11-06 12:58:19 +0000
committerJens Axboe <axboe@kernel.dk>2025-11-06 16:25:18 -0700
commit93e197e524b14d185d011813b72773a1a49d932d (patch)
tree141ef68b02709dea884a8198cc682c91015cd2d0
parent75c299a917e4547dfe640ce7fd83c8a14d8409d0 (diff)
io_uring: use WRITE_ONCE for user shared memory
IORING_SETUP_NO_MMAP rings remain user accessible even before the ctx setup is finalised, so use WRITE_ONCE consistently when initialising rings. Fixes: 03d89a2de25bb ("io_uring: support for user allocated memory for rings/sqes") Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/io_uring.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index e493d4358ab7..d11d0e9723a1 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -3381,10 +3381,6 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx,
if (!(ctx->flags & IORING_SETUP_NO_SQARRAY))
ctx->sq_array = (u32 *)((char *)rings + sq_array_offset);
- rings->sq_ring_mask = p->sq_entries - 1;
- rings->cq_ring_mask = p->cq_entries - 1;
- rings->sq_ring_entries = p->sq_entries;
- rings->cq_ring_entries = p->cq_entries;
memset(&rd, 0, sizeof(rd));
rd.size = PAGE_ALIGN(sq_size);
@@ -3398,6 +3394,12 @@ static __cold int io_allocate_scq_urings(struct io_ring_ctx *ctx,
return ret;
}
ctx->sq_sqes = io_region_get_ptr(&ctx->sq_region);
+
+ memset(rings, 0, sizeof(*rings));
+ WRITE_ONCE(rings->sq_ring_mask, ctx->sq_entries - 1);
+ WRITE_ONCE(rings->cq_ring_mask, ctx->cq_entries - 1);
+ WRITE_ONCE(rings->sq_ring_entries, ctx->sq_entries);
+ WRITE_ONCE(rings->cq_ring_entries, ctx->cq_entries);
return 0;
}