mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
io_uring: fix race condition reading SQ entries
A read memory barrier is required between reading SQ tail and reading the actual data belonging to the SQ entry. Userspace needs a matching write barrier between writing SQ entries and updating SQ tail (using smp_store_release to update tail will do). Signed-off-by: Stefan Bühler <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
35fa71a030
commit
e523a29c4f
1 changed files with 2 additions and 1 deletions
|
|
@ -1739,7 +1739,8 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s)
|
|||
head = ctx->cached_sq_head;
|
||||
/* See comment at the top of this file */
|
||||
smp_rmb();
|
||||
if (head == READ_ONCE(ring->r.tail))
|
||||
/* make sure SQ entry isn't read before tail */
|
||||
if (head == smp_load_acquire(&ring->r.tail))
|
||||
return false;
|
||||
|
||||
head = READ_ONCE(ring->array[head & ctx->sq_mask]);
|
||||
|
|
|
|||
Loading…
Reference in a new issue