From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 2/2] io_uring: fix unsynchronised removal of sq_data
Date: Mon, 28 Sep 2020 14:49:50 +0300 [thread overview]
Message-ID: <1647bc3920b40771429afb28a2b82d9c9cb1e6c6.1601293611.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>
Remove io_sq_thread_stop() from io_uring_flush() and just clear
->sqo_files, etc. instead. The first reason is that io_sq_thread_stop()
null's ctx->sq_data without any lock held, that's racy. Also, it kills
an SQPOLL thread even though there may be other processes wanting to
continue using the io_uring instance.
[email protected]
Signed-off-by: Pavel Begunkov <[email protected]>
---
fs/io_uring.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 6523500e4ae2..0ab0c3aefefd 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8548,13 +8548,7 @@ static int io_uring_flush(struct file *file, void *data)
{
struct io_ring_ctx *ctx = file->private_data;
- /*
- * If the task is going away, cancel work it may have pending
- */
- if (fatal_signal_pending(current) || (current->flags & PF_EXITING)) {
- io_sq_thread_stop(ctx);
- io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb, current, true);
- } else if (ctx->flags & IORING_SETUP_SQPOLL) {
+ if (ctx->flags & IORING_SETUP_SQPOLL) {
struct io_sq_data *sqd = ctx->sq_data;
/* Ring is being closed, mark us as neding new assignment */
@@ -8568,6 +8562,12 @@ static int io_uring_flush(struct file *file, void *data)
io_sq_thread_unpark(sqd);
}
+ /*
+ * If the task is going away, cancel work it may have pending
+ */
+ if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
+ io_wq_cancel_cb(ctx->io_wq, io_cancel_task_cb, current, true);
+
io_uring_cancel_files(ctx, data);
return 0;
--
2.24.0
next prev parent reply other threads:[~2020-09-28 11:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 11:49 [PATCH 0/2] ->flush() fixes Pavel Begunkov
2020-09-28 11:49 ` [PATCH 1/2] io_uring: fix use-after-free ->files Pavel Begunkov
2020-09-28 11:49 ` Pavel Begunkov [this message]
2020-09-28 12:23 ` [PATCH 0/2] ->flush() fixes Pavel Begunkov
2020-09-28 13:35 ` 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=1647bc3920b40771429afb28a2b82d9c9cb1e6c6.1601293611.git.asml.silence@gmail.com \
[email protected] \
[email protected] \
[email protected] \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox