From: Andrew Stellman <bugs@stellman-greene.com>
To: Stefano Garzarella <sgarzare@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Cc: "Bobby Eshleman" <bobbyeshleman@meta.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowangio@gmail.com>,
"Eugenio Pérez" <eperezma@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"Simon Horman" <horms@kernel.org>,
virtualization@lists.linux.dev, kvm@vger.kernel.org,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH net v3] vsock: wait for EOM before reporting SEQPACKET readable
Date: Sat, 5 Dec 2026 14:15:32 -0500 [thread overview]
Message-ID: <20261205191532.24016-1-bugs@stellman-greene.com> (raw)
From: Andrew Stellman <astellman@stellman-greene.com>
For SOCK_SEQPACKET, virtio_transport_notify_poll_in() checks the number
of queued bytes, so poll and epoll report the socket readable before the
packet carrying EOM has arrived, while a nonblocking recv still fails
with -EAGAIN. vsock_data_ready() also compares queued bytes with
SO_RCVLOWAT, so a complete message shorter than SO_RCVLOWAT does not
wake blocked poll or epoll waiters. Check for a complete message in
notify_poll_in() for SEQPACKET, and apply SO_RCVLOWAT in
vsock_data_ready() only to SOCK_STREAM, so SO_RCVLOWAT no longer affects
SEQPACKET readiness and each SEQPACKET packet carrying data still
triggers a data-ready callback.
The issue was found by Claude Opus 5 running Quality Playbook, an
LLM-driven code review tool:
https://github.com/andrewstellman/quality-playbook
The fix was drafted with OpenAI GPT-6 (Codex), this changelog with
OpenAI GPT-6 (Codex) and Claude Opus 5.5, and both were reviewed by me.
Fixes: 9ac841f5e9f2 ("virtio/vsock: rest of SOCK_SEQPACKET support")
Signed-off-by: Andrew Stellman <astellman@stellman-greene.com>
---
v3: Keep a data-ready callback for each packet carrying data, since v2
broke BPF sockmap verdicts on a two-fragment message, and use Bobby
Eshleman's form for the threshold.
v2: https://lore.kernel.org/all/20261203184926.10262-1-bugs@stellman-greene.com/
v1: https://lore.kernel.org/all/20261202181307.73934-1-bugs@stellman-greene.com/
Tested on net 90ae4042bd9f in arm64 QEMU with KASAN and vsock
loopback: with a test-only delay before EOM, poll/epoll reported
readable while recv returned -EAGAIN on plain net but not on v3; a
26-byte message under SO_RCVLOWAT=4096 woke poll/epoll only on v3; a
BPF sockmap verdict saw both fragments on plain net and v3 but one on
v2; vsock_test passed.
A reproducer is available on request.
net/vmw_vsock/af_vsock.c | 6 +++++-
net/vmw_vsock/virtio_transport_common.c | 5 ++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 1d7d53542724..8f3daee52d45 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1118,8 +1118,12 @@ EXPORT_SYMBOL_GPL(vsock_stream_has_space);
void vsock_data_ready(struct sock *sk)
{
struct vsock_sock *vsk = vsock_sk(sk);
+ int target = 1;
- if (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat ||
+ if (sk->sk_type == SOCK_STREAM)
+ target = sk->sk_rcvlowat;
+
+ if (vsock_stream_has_data(vsk) >= target ||
sock_flag(sk, SOCK_DONE))
sk->sk_data_ready(sk);
}
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
index 1e762a480df4..7baab79d5808 100644
--- a/net/vmw_vsock/virtio_transport_common.c
+++ b/net/vmw_vsock/virtio_transport_common.c
@@ -1107,7 +1107,10 @@ 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;
+ 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;
}
reply other threads:[~2026-12-05 19:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261205191532.24016-1-bugs@stellman-greene.com \
--to=bugs@stellman-greene.com \
--cc=bobbyeshleman@meta.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=eperezma@redhat.com \
--cc=horms@kernel.org \
--cc=jasowangio@gmail.com \
--cc=kuba@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=willemb@google.com \
--cc=xuanzhuo@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox