From: "Pavel Begunkov (Silence)" <asml.silence@gmail.com>
To: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Pavel Begunkov <asml.silence@gmail.com>
Subject: [PATCH 3/3] io_uring: Fix race for sqes with userspace
Date: Fri, 25 Oct 2019 12:31:31 +0300 [thread overview]
Message-ID: <cfb7206ba1ac48615fd705ac74fc2d554a0c5422.1571991701.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1571991701.git.asml.silence@gmail.com>
From: Pavel Begunkov <asml.silence@gmail.com>
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: Pavel Begunkov <asml.silence@gmail.com>
---
fs/io_uring.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 949c82a40d16..32f6598ecae9 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2795,13 +2795,14 @@ static int io_ring_submit(struct io_ring_ctx *ctx, unsigned int to_submit)
submit++;
io_submit_sqe(ctx, &s, statep, &link);
}
- io_commit_sqring(ctx);
if (link)
io_queue_link_head(ctx, link, &link->submit, shadow_req);
if (statep)
io_submit_state_end(statep);
+ io_commit_sqring(ctx);
+
return submit;
}
--
2.23.0
next prev parent reply other threads:[~2019-10-25 9:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 9:31 [PATCH 0/3][for-linus] Fix bunch of bugs in io_uring Pavel Begunkov (Silence)
2019-10-25 9:31 ` [PATCH 1/3] io_uring: Fix corrupted user_data Pavel Begunkov (Silence)
2019-10-25 9:31 ` [PATCH 2/3] io_uring: Fix broken links with offloading Pavel Begunkov (Silence)
2019-10-25 9:36 ` Pavel Begunkov
2019-10-25 15:01 ` Jens Axboe
2019-10-25 9:31 ` Pavel Begunkov (Silence) [this message]
2019-10-25 15:01 ` [PATCH 0/3][for-linus] Fix bunch of bugs in io_uring Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cfb7206ba1ac48615fd705ac74fc2d554a0c5422.1571991701.git.asml.silence@gmail.com \
--to=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.