提交 c88434f7 编写于 作者: S Stefan Bühler 提交者: Cheng Jian

io_uring: fix race condition reading SQ entries

mainline inclusion
from mainline-5.1-rc7
commit e523a29c
category: feature
bugzilla: https://bugzilla.openeuler.org/show_bug.cgi?id=27
CVE: NA
---------------------------

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: NStefan Bühler <source@stbuehler.de>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NZhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: Nzhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 7d48a975
...@@ -1736,7 +1736,8 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s) ...@@ -1736,7 +1736,8 @@ static bool io_get_sqring(struct io_ring_ctx *ctx, struct sqe_submit *s)
head = ctx->cached_sq_head; head = ctx->cached_sq_head;
/* See comment at the top of this file */ /* See comment at the top of this file */
smp_rmb(); 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; return false;
head = READ_ONCE(ring->array[head & ctx->sq_mask]); head = READ_ONCE(ring->array[head & ctx->sq_mask]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册