Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Pavel Begunkov and committed by
Jens Axboe
93e197e5 75c299a9

+6 -4
+6 -4
io_uring/io_uring.c
··· 3381 3381 3382 3382 if (!(ctx->flags & IORING_SETUP_NO_SQARRAY)) 3383 3383 ctx->sq_array = (u32 *)((char *)rings + sq_array_offset); 3384 - rings->sq_ring_mask = p->sq_entries - 1; 3385 - rings->cq_ring_mask = p->cq_entries - 1; 3386 - rings->sq_ring_entries = p->sq_entries; 3387 - rings->cq_ring_entries = p->cq_entries; 3388 3384 3389 3385 memset(&rd, 0, sizeof(rd)); 3390 3386 rd.size = PAGE_ALIGN(sq_size); ··· 3394 3398 return ret; 3395 3399 } 3396 3400 ctx->sq_sqes = io_region_get_ptr(&ctx->sq_region); 3401 + 3402 + memset(rings, 0, sizeof(*rings)); 3403 + WRITE_ONCE(rings->sq_ring_mask, ctx->sq_entries - 1); 3404 + WRITE_ONCE(rings->cq_ring_mask, ctx->cq_entries - 1); 3405 + WRITE_ONCE(rings->sq_ring_entries, ctx->sq_entries); 3406 + WRITE_ONCE(rings->cq_ring_entries, ctx->cq_entries); 3397 3407 return 0; 3398 3408 } 3399 3409