]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
io_uring/net: fix sr->len for IORING_OP_RECV with MSG_WAITALL and buffers
authorJens Axboe <axboe@kernel.dk>
Thu, 1 Feb 2024 13:42:36 +0000 (06:42 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Feb 2024 18:14:29 +0000 (19:14 +0100)
commit5f42b16f8656153da78e1f66744840e76e4465b1
tree3b3ee7f8491d55bffa3bf72033a2078cf2dea161
parent30f3841215b7ebc350e123609bff696e8b5f96bc
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>
io_uring/net.c