提交 332ec4c6 编写于 作者: P Pavel Begunkov 提交者: Joseph Qi

io_uring: Fix race for sqes with userspace

commit 935d1e45908afb8853c497f2c2bbbb685dec51dc upstream.

io_ring_submit() finalises with
1. io_commit_sqring(), which releases sqes to the userspace
2. Then calls to io_queue_link_head(), accessing released head's sqe

Reorder them.
Signed-off-by: NPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
Signed-off-by: NJoseph Qi <joseph.qi@linux.alibaba.com>
Reviewed-by: NXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
上级 777f45c0
...@@ -2794,13 +2794,14 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit) ...@@ -2794,13 +2794,14 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
submit++; submit++;
io_submit_sqe(ctx, &s, statep, &link); io_submit_sqe(ctx, &s, statep, &link);
} }
io_commit_sqring(ctx);
if (link) if (link)
io_queue_link_head(ctx, link, &link->submit, shadow_req); io_queue_link_head(ctx, link, &link->submit, shadow_req);
if (statep) if (statep)
io_submit_state_end(statep); io_submit_state_end(statep);
io_commit_sqring(ctx);
return submit; return submit;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册