All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] vsock/virtio: wait for EOM before reporting SEQPACKET readable
@ 2026-12-02 18:13 Andrew Stellman
  2026-12-02 23:15 ` Bobby Eshleman
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Stellman @ 2026-12-02 18:13 UTC (permalink / raw)
  To: Stefan Hajnoczi, Stefano Garzarella
  Cc: Bobby Eshleman, Michael S. Tsirkin, Jason Wang,
	Eugenio Pérez, Xuan Zhuo, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, virtualization, kvm,
	netdev, linux-kernel

From: Andrew Stellman <astellman@stellman-greene.com>

virtio_transport_notify_poll_in() compares queued bytes with the
receive low-water mark for every socket type, but SEQPACKET recv() only
returns a message once its EOM packet has arrived. When only the first
packet of a message larger than 64 KiB is queued, poll() and epoll
report the socket readable and a nonblocking recv() returns EAGAIN.

Use the completed-message count for SEQPACKET, as recv() does. An
incomplete message is no longer reported readable, and SO_RCVLOWAT no
longer affects SEQPACKET poll.

Fixes: 9ac841f5e9f2 ("virtio/vsock: rest of SOCK_SEQPACKET support")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
Tested on mainline 693c2e04e3f1 (7.4.0-rc5) in arm64 QEMU with KASAN
over vsock loopback, with a test-only three-second delay after the
first packet: before the fix poll() and epoll reported the socket
readable while recv() returned EAGAIN, and with the fix they didn't.

Found with Quality Playbook
(https://github.com/andrewstellman/quality-playbook) running Claude
Opus 5; the fix was drafted with OpenAI GPT-6 (Codex).

A reproducer is available on request.

 net/vmw_vsock/virtio_transport_common.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 1e762a480df4..d659986bb48b 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -1107,7 +1107,11 @@ virtio_transport_notify_poll_in(struct vsock_sock *vsk,
 				size_t target,
 				bool *data_ready_now)
 {
-	*data_ready_now = vsock_stream_has_data(vsk) >= target;
+	/* A SEQPACKET message is readable only after its EOM packet arrives. */
+	if (sk_vsock(vsk)->sk_type == SOCK_SEQPACKET)
+		*data_ready_now = virtio_transport_seqpacket_has_data(vsk) != 0;
+	else
+		*data_ready_now = vsock_stream_has_data(vsk) >= target;
 
 	return 0;
 }
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 23:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 18:13 [PATCH net] vsock/virtio: wait for EOM before reporting SEQPACKET readable Andrew Stellman
2026-12-02 23:15 ` Bobby Eshleman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.