This is a note to let you know that I've just added the patch titled io_uring/net: fix sr->len for IORING_OP_RECV with MSG_WAITALL and buffers to the 6.6-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-net-fix-sr-len-for-ioring_op_recv-with-msg_waitall-and-buffers.patch and it can be found in the queue-6.6 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From 72bd80252feeb3bef8724230ee15d9f7ab541c6e Mon Sep 17 00:00:00 2001 From: Jens Axboe <axboe@xxxxxxxxx> Date: Thu, 1 Feb 2024 06:42:36 -0700 Subject: io_uring/net: fix sr->len for IORING_OP_RECV with MSG_WAITALL and buffers From: Jens Axboe <axboe@xxxxxxxxx> 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@xxxxxxxxxxxxxxx Fixes: 7ba89d2af17a ("io_uring: ensure recv and recvmsg handle MSG_WAITALL correctly") Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- io_uring/net.c | 1 + 1 file changed, 1 insertion(+) --- a/io_uring/net.c +++ b/io_uring/net.c @@ -902,6 +902,7 @@ retry_multishot: if (!buf) return -ENOBUFS; sr->buf = buf; + sr->len = len; } ret = import_ubuf(ITER_DEST, sr->buf, len, &msg.msg_iter); Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-6.6/blk-iocost-fix-an-ubsan-shift-out-of-bounds-warning.patch queue-6.6/io_uring-net-fix-sr-len-for-ioring_op_recv-with-msg_waitall-and-buffers.patch queue-6.6/io_uring-net-un-indent-mshot-retry-path-in-io_recv_finish.patch