From: Pavel Begunkov <asml.silence@gmail.com>
To: io-uring@vger.kernel.org
Cc: asml.silence@gmail.com, Anuj gupta <anuj1072538@gmail.com>,
	Jens Axboe <axboe@kernel.dk>
Subject: [PATCH v2 4/6] io_uring/rw: shrink io_iov_compat_buffer_select_prep
Date: Mon, 24 Feb 2025 12:42:22 +0000	[thread overview]
Message-ID: <b334a3a5040efa424ded58e4d8a6ef2554324266.1740400452.git.asml.silence@gmail.com> (raw)
In-Reply-To: <cover.1740400452.git.asml.silence@gmail.com>

Compat performance is not important and simplicity is more appreciated.
Let's not be smart about it and use simpler copy_from_user() instead of
access + __get_user pair.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
---
 io_uring/rw.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/io_uring/rw.c b/io_uring/rw.c
index 7133029b4396..22612a956e75 100644
--- a/io_uring/rw.c
+++ b/io_uring/rw.c
@@ -48,18 +48,12 @@ static bool io_file_supports_nowait(struct io_kiocb *req, __poll_t mask)
 
 static int io_iov_compat_buffer_select_prep(struct io_rw *rw)
 {
-	struct compat_iovec __user *uiov;
-	compat_ssize_t clen;
+	struct compat_iovec __user *uiov = u64_to_user_ptr(rw->addr);
+	struct compat_iovec iov;
 
-	uiov = u64_to_user_ptr(rw->addr);
-	if (!access_ok(uiov, sizeof(*uiov)))
-		return -EFAULT;
-	if (__get_user(clen, &uiov->iov_len))
+	if (copy_from_user(&iov, uiov, sizeof(iov)))
 		return -EFAULT;
-	if (clen < 0)
-		return -EINVAL;
-
-	rw->len = clen;
+	rw->len = iov.iov_len;
 	return 0;
 }
 
-- 
2.48.1


  parent reply	other threads:[~2025-02-24 12:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24 12:42 [PATCH v2 0/6] compile out ctx->compat reads Pavel Begunkov
2025-02-24 12:42 ` [PATCH v2 1/6] io_uring: introduce io_is_compat() Pavel Begunkov
2025-02-24 13:20   ` Anuj gupta
2025-02-24 12:42 ` [PATCH v2 2/6] io_uring/cmd: optimise !CONFIG_COMPAT flags setting Pavel Begunkov
2025-02-24 13:21   ` Anuj gupta
2025-02-24 12:42 ` [PATCH v2 3/6] io_uring/rw: compile out compat param passing Pavel Begunkov
2025-02-24 13:22   ` Anuj gupta
2025-02-24 12:42 ` Pavel Begunkov [this message]
2025-02-24 12:42 ` [PATCH v2 5/6] io_uring/waitid: use io_is_compat() Pavel Begunkov
2025-02-24 13:23   ` Anuj gupta
2025-02-24 15:33   ` Caleb Sander Mateos
2025-02-24 16:12     ` Pavel Begunkov
2025-02-24 12:42 ` [PATCH v2 6/6] io_uring/net: " Pavel Begunkov
2025-02-24 13:23   ` Anuj gupta
2025-02-24 14:35 ` [PATCH v2 0/6] compile out ctx->compat reads 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=b334a3a5040efa424ded58e4d8a6ef2554324266.1740400452.git.asml.silence@gmail.com \
    --to=asml.silence@gmail.com \
    --cc=anuj1072538@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=io-uring@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.