]> git.hungrycats.org Git - linux/commitdiff
io_uring/net: keep recvmsg buffer select length within MAX_RW_COUNT
authorYichong Chen <chenyichong@uniontech.com>
Wed, 4 Nov 2026 18:44:33 +0000 (11:44 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:52 +0000 (12:10 -0500)
Commit 18d3f56eb6e6500a65d81cf265f0fe74fd9ecab6 upstream.

io_recvmsg() takes the transfer length from the ring provided buffer when
sqe->len is 0, and such a buffer can be up to 4G. min_ret is an int, so 2G
or more makes it negative and the (ret < min_ret) block is skipped, and the
oversized length reaches the socket layer unchanged: an empty socket then
completes with 0 instead of arming poll, and a short read is reported as
complete. Clamp the length to MAX_RW_COUNT, as io_recv() does.

Fixes: c7fb19428d67 ("io_uring: add support for ring mapped supplied buffers")
Signed-off-by: Yichong Chen <chenyichong@uniontech.com>
Link: https://patch.msgid.link/20261023112209.87979-1-chenyichong@uniontech.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
io_uring/net.c

index eeab88e77fd81b86d2e5b707b523585798107860..4678f29f51773ba2dd2d4afdd35538068ebf2baa 100644 (file)
@@ -1068,6 +1068,7 @@ retry_multishot:
                sel = io_buffer_select(req, &len, sr->buf_group, issue_flags);
                if (!sel.addr)
                        return -ENOBUFS;
+               len = min_t(size_t, len, MAX_RW_COUNT);
 
                if (req->flags & REQ_F_APOLL_MULTISHOT) {
                        ret = io_recvmsg_prep_multishot(kmsg, sr, &sel.addr, &len);