Skip to content

Commit bba5af8

Browse files
axboesmb49
authored andcommitted
io_uring/net: fix sr->len for IORING_OP_RECV with MSG_WAITALL and buffers
BugLink: https://bugs.launchpad.net/bugs/2059991 commit 72bd802 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: 7ba89d2 ("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> Signed-off-by: Portia Stephens <portia.stephens@canonical.com> Signed-off-by: Roxana Nicolescu <roxana.nicolescu@canonical.com>
1 parent 374f5d1 commit bba5af8

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

io_uring/net.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
902902
if (!buf)
903903
return -ENOBUFS;
904904
sr->buf = buf;
905+
sr->len = len;
905906
}
906907

907908
ret = import_ubuf(ITER_DEST, sr->buf, len, &msg.msg_iter);

0 commit comments

Comments
 (0)