summaryrefslogtreecommitdiff
path: root/io_uring
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-02-01 16:42:36 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2024-02-16 21:06:30 +0300
commitfbd77ce1d1748239bb60317ddae3b75e18d51cf2 (patch)
treefb24af8f3bc8a99b885ac35c6b25a3849b6d1c44 /io_uring
parent08249dc3d9c1a6a54e9ad04148d0def5f8deff2e (diff)
downloadlinux-fbd77ce1d1748239bb60317ddae3b75e18d51cf2.tar.xz
io_uring/net: fix sr->len for IORING_OP_RECV with MSG_WAITALL and buffers
commit 72bd80252feeb3bef8724230ee15d9f7ab541c6e upstream. If we use IORING_OP_RECV with provided buffers and pass in '0' as the length of the request, the length is retrieved from the selected buffer. If MSG_WAITALL is also set and we get a short receive, then we may hit the retry path which decrements sr->len and increments the buffer for a retry. However, the length is still zero at this point, which means that sr->len now becomes huge and import_ubuf() will cap it to MAX_RW_COUNT and subsequently return -EFAULT for the range as a whole. Fix this by always assigning sr->len once the buffer has been selected. Cc: stable@vger.kernel.org Fixes: 7ba89d2af17a ("io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly") Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'io_uring')
-rw-r--r--io_uring/net.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/io_uring/net.c b/io_uring/net.c
index 67f09a40bcb2..618ab186fe03 100644
--- a/io_uring/net.c
+++ b/io_uring/net.c
@@ -875,6 +875,7 @@ retry_multishot:
if (!buf)
return -ENOBUFS;
sr->buf = buf;
+ sr->len = len;
}
ret = import_single_range(ITER_DEST, sr->buf, len, &iov, &msg.msg_iter);