public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>, [email protected]
Subject: [PATCH 1/2] io_uring: fix use-after-free ->files
Date: Mon, 28 Sep 2020 14:49:49 +0300	[thread overview]
Message-ID: <71e7baae4ff3b745e13c685c39121af6e13ddea4.1601293611.git.asml.silence@gmail.com> (raw)
In-Reply-To: <[email protected]>

io_uring_flush() should first clear ->sqo_files and only then trying to
cancel requests with io_uring_cancel_files(). Otherwise, SQ thread may
wake up right after io_uring_cancel_file() and submit new requests with
the going away files.

Signed-off-by: Pavel Begunkov <[email protected]>
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 7ee5e18218c2..6523500e4ae2 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -8548,8 +8548,6 @@ static int io_uring_flush(struct file *file, void *data)
 {
 	struct io_ring_ctx *ctx = file->private_data;
 
-	io_uring_cancel_files(ctx, data);
-
 	/*
 	 * If the task is going away, cancel work it may have pending
 	 */
@@ -8570,6 +8568,8 @@ static int io_uring_flush(struct file *file, void *data)
 		io_sq_thread_unpark(sqd);
 	}
 
+	io_uring_cancel_files(ctx, data);
+
 	return 0;
 }
 
-- 
2.24.0


  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 ` Pavel Begunkov [this message]
2020-09-28 11:49 ` [PATCH 2/2] io_uring: fix unsynchronised removal of sq_data Pavel Begunkov
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=71e7baae4ff3b745e13c685c39121af6e13ddea4.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