From: Ruide Cao __vsock_stream_recvmsg() passes its receive timeout by value to vsock_connectible_wait_data(). schedule_timeout() therefore updates only the helper's local copy. After a partial dequeue, the stream receive loop calls the helper again with the original timeout, allowing a peer to restart SO_RCVTIMEO with periodic short writes. This was found with LLM assistance on the Vega platform and reproduced with the platform PoC in QEMU as an unprivileged user on VMADDR_CID_LOCAL. recv(MSG_WAITALL, 6) with SO_RCVTIMEO=1s returned 6 bytes after ~4.8s while the peer sent one byte every 0.8s: client: recv(MSG_WAITALL, 6) returned 6 after 4.816 s (timeout=1 s) RESULT: bug observed. Finite SO_RCVTIMEO did not cap total wait time. Pass the timeout by reference so the remaining time is retained across partial reads. This makes the receive wait budget cumulative without changing the existing blocking behavior. The seqpacket call site is updated the same way; it only waits once, so the change is mechanical. Fixes: b3f7fd54881b ("af_vsock: separate wait data loop") Cc: stable@vger.kernel.org Reported-by: Vega Signed-off-by: Ruide Cao Signed-off-by: Ren Wei --- net/vmw_vsock/af_vsock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 1d7d53542724..99542ac080b4 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -2406,7 +2406,7 @@ static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, static int vsock_connectible_wait_data(struct sock *sk, struct wait_queue_entry *wait, - long timeout, + long *timeout, struct vsock_transport_recv_notify_data *recv_data, size_t target) { @@ -2432,7 +2432,7 @@ static int vsock_connectible_wait_data(struct sock *sk, } /* Don't wait for non-blocking sockets. */ - if (timeout == 0) { + if (*timeout == 0) { err = -EAGAIN; break; } @@ -2444,13 +2444,13 @@ static int vsock_connectible_wait_data(struct sock *sk, } release_sock(sk); - timeout = schedule_timeout(timeout); + *timeout = schedule_timeout(*timeout); lock_sock(sk); if (signal_pending(current)) { - err = sock_intr_errno(timeout); + err = sock_intr_errno(*timeout); break; - } else if (timeout == 0) { + } else if (*timeout == 0) { err = -EAGAIN; break; } @@ -2509,7 +2509,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg, while (1) { ssize_t read; - err = vsock_connectible_wait_data(sk, &wait, timeout, + err = vsock_connectible_wait_data(sk, &wait, &timeout, &recv_data, target); if (err <= 0) break; @@ -2565,7 +2565,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, timeout = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); - err = vsock_connectible_wait_data(sk, &wait, timeout, NULL, 0); + err = vsock_connectible_wait_data(sk, &wait, &timeout, NULL, 0); if (err <= 0) goto out; -- 2.47.3