Skip to content

Commit

Permalink
io_uring: support 0 length iov in buffer select in compat
Browse files Browse the repository at this point in the history
Match up work done in "io_uring: allow iov_len = 0 for recvmsg and buffer
select", but for compat code path.

Fixes: a68caad ("io_uring: allow iov_len = 0 for recvmsg and buffer select")
Signed-off-by: Dylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220708181838.1495428-3-dylany@fb.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Dylan Yudaken authored and Jens Axboe committed Jul 25, 2022
1 parent e2df2cc commit 6d2f75a
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions io_uring/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,16 +382,21 @@ static int __io_compat_recvmsg_copy_hdr(struct io_kiocb *req,
if (req->flags & REQ_F_BUFFER_SELECT) {
compat_ssize_t clen;

if (len > 1)
return -EINVAL;
if (!access_ok(uiov, sizeof(*uiov)))
return -EFAULT;
if (__get_user(clen, &uiov->iov_len))
return -EFAULT;
if (clen < 0)
if (len == 0) {
sr->len = 0;
iomsg->free_iov = NULL;
} else if (len > 1) {
return -EINVAL;
sr->len = clen;
iomsg->free_iov = NULL;
} else {
if (!access_ok(uiov, sizeof(*uiov)))
return -EFAULT;
if (__get_user(clen, &uiov->iov_len))
return -EFAULT;
if (clen < 0)
return -EINVAL;
sr->len = clen;
iomsg->free_iov = NULL;
}
} else {
iomsg->free_iov = iomsg->fast_iov;
ret = __import_iovec(READ, (struct iovec __user *)uiov, len,
Expand Down

0 comments on commit 6d2f75a

Please sign in to comment.