summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2025-02-26 11:41:16 +0000
committerJens Axboe <axboe@kernel.dk>2025-02-27 07:27:37 -0700
commit0fc5a589aff7f9e613ff94fd3dd0a6686ffcb706 (patch)
tree56112a4d86e2836092a468fae42507a6b82935b6
parent80b3de7da7d2525c4a5f20fb7248366d42b4e4fb (diff)
io_uring/net: simplify compat selbuf iov parsing
Use copy_from_user() instead of open coded access_ok() + get_user(), that's simpler and we don't care about compat that much. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Link: https://lore.kernel.org/r/e51f9c323a3cd4ad7c8da656559bdf6237f052fb.1740569495.git.asml.silence@gmail.com [axboe: fold in bogus < 0 check for tmp_iov.iov_len] Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--io_uring/net.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/io_uring/net.c b/io_uring/net.c
index c78edfd5085e..dc1569864799 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -215,21 +215,17 @@ static int io_compat_msg_copy_hdr(struct io_kiocb *req,
uiov = compat_ptr(msg->msg_iov);
if (req->flags & REQ_F_BUFFER_SELECT) {
- compat_ssize_t clen;
-
if (msg->msg_iovlen == 0) {
sr->len = iov->iov_len = 0;
iov->iov_base = NULL;
} else if (msg->msg_iovlen > 1) {
return -EINVAL;
} else {
- if (!access_ok(uiov, sizeof(*uiov)))
- return -EFAULT;
- if (__get_user(clen, &uiov->iov_len))
+ struct compat_iovec tmp_iov;
+
+ if (copy_from_user(&tmp_iov, uiov, sizeof(tmp_iov)))
return -EFAULT;
- if (clen < 0)
- return -EINVAL;
- sr->len = clen;
+ sr->len = tmp_iov.iov_len;
}
return 0;