public inbox for [email protected]
 help / color / mirror / Atom feed
From: Pavel Begunkov <[email protected]>
To: Jens Axboe <[email protected]>,
	[email protected], [email protected]
Subject: [PATCH] io_uring: fix mm use with IORING_OP_{READ,WRITE}
Date: Wed,  5 Feb 2020 18:46:14 +0300	[thread overview]
Message-ID: <951bb84c8337aaac7654261a21b03506b2b8a001.1580914723.git.asml.silence@gmail.com> (raw)

IORING_OP_{READ,WRITE} need mm to access user buffers, hence
req->has_user check should go for them as well. Move the corresponding
imports past the check.

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 edb00ae2619b..f00c2c9c67c0 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -2038,13 +2038,6 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
 	if (req->rw.kiocb.private)
 		return -EINVAL;
 
-	if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
-		ssize_t ret;
-		ret = import_single_range(rw, buf, sqe_len, *iovec, iter);
-		*iovec = NULL;
-		return ret;
-	}
-
 	if (req->io) {
 		struct io_async_rw *iorw = &req->io->rw;
 
@@ -2058,6 +2051,13 @@ static ssize_t io_import_iovec(int rw, struct io_kiocb *req,
 	if (!req->has_user)
 		return -EFAULT;
 
+	if (opcode == IORING_OP_READ || opcode == IORING_OP_WRITE) {
+		ssize_t ret;
+		ret = import_single_range(rw, buf, sqe_len, *iovec, iter);
+		*iovec = NULL;
+		return ret;
+	}
+
 #ifdef CONFIG_COMPAT
 	if (req->ctx->compat)
 		return compat_import_iovec(rw, buf, sqe_len, UIO_FASTIOV,
-- 
2.24.0


             reply	other threads:[~2020-02-05 15:47 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-05 15:46 Pavel Begunkov [this message]
2020-02-05 15:54 ` [PATCH] io_uring: fix mm use with IORING_OP_{READ,WRITE} Jens Axboe
2020-02-05 16:02   ` Pavel Begunkov
2020-02-05 16:05     ` Jens Axboe
2020-02-05 16:16       ` Jens Axboe
2020-02-05 16:50         ` Pavel Begunkov
2020-02-05 16:52           ` Jens Axboe
2020-02-05 16:59             ` Pavel Begunkov

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=951bb84c8337aaac7654261a21b03506b2b8a001.1580914723.git.asml.silence@gmail.com \
    [email protected] \
    [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