]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
io_uring/rw: shrink io_iov_compat_buffer_select_prep
authorPavel Begunkov <asml.silence@gmail.com>
Mon, 24 Feb 2025 12:42:22 +0000 (12:42 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 24 Feb 2025 14:34:21 +0000 (07:34 -0700)
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>
Link: https://lore.kernel.org/r/b334a3a5040efa424ded58e4d8a6ef2554324266.1740400452.git.asml.silence@gmail.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/rw.c

index 7133029b439668410da41d9ed756f2025b4cd14f..22612a956e75a942193fd30214e22296bfb0a6b5 100644 (file)
@@ -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;
 }