Commit 5702196e authored by Dylan Yudaken's avatar Dylan Yudaken Committed by Jens Axboe

io_uring: allow iov_len = 0 for recvmsg and buffer select

When using BUFFER_SELECT there is no technical requirement that the user
actually provides iov, and this removes one copy_from_user call.

So allow iov_len to be 0.
Signed-off-by: default avatarDylan Yudaken <dylany@fb.com>
Link: https://lore.kernel.org/r/20220630091231.1456789-4-dylany@fb.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 32f3c434
...@@ -300,12 +300,18 @@ static int __io_recvmsg_copy_hdr(struct io_kiocb *req, ...@@ -300,12 +300,18 @@ static int __io_recvmsg_copy_hdr(struct io_kiocb *req,
return ret; return ret;
if (req->flags & REQ_F_BUFFER_SELECT) { if (req->flags & REQ_F_BUFFER_SELECT) {
if (iov_len > 1) if (iov_len == 0) {
sr->len = iomsg->fast_iov[0].iov_len = 0;
iomsg->fast_iov[0].iov_base = NULL;
iomsg->free_iov = NULL;
} else if (iov_len > 1) {
return -EINVAL; return -EINVAL;
} else {
if (copy_from_user(iomsg->fast_iov, uiov, sizeof(*uiov))) if (copy_from_user(iomsg->fast_iov, uiov, sizeof(*uiov)))
return -EFAULT; return -EFAULT;
sr->len = iomsg->fast_iov[0].iov_len; sr->len = iomsg->fast_iov[0].iov_len;
iomsg->free_iov = NULL; iomsg->free_iov = NULL;
}
} else { } else {
iomsg->free_iov = iomsg->fast_iov; iomsg->free_iov = iomsg->fast_iov;
ret = __import_iovec(READ, uiov, iov_len, UIO_FASTIOV, ret = __import_iovec(READ, uiov, iov_len, UIO_FASTIOV,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment