Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: bugs@stellman-greene.com
Cc: stefanha@redhat.com, sgarzare@redhat.com, bobbyeshleman@meta.com,
	mst@redhat.com, jasowangio@gmail.com, eperezma@redhat.com,
	xuanzhuo@linux.alibaba.com, davem@davemloft.net,
	edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
	horms@kernel.org, virtualization@lists.linux.dev,
	kvm@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] vsock/virtio: wait for EOM before reporting SEQPACKET readable
Date: Thu, 03 Dec 2026 19:10:59 +0000	[thread overview]
Message-ID: <179632505944.3146.4004115120950433578@kernel.org> (raw)
In-Reply-To: <20261202181307.73934-1-bugs@stellman-greene.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The patch changes when poll() reports a SEQPACKET socket
  readable, but it does not change when sleeping pollers are woken.

--

vsock/virtio: wait for EOM before reporting SEQPACKET readable

For SEQPACKET sockets, this patch changes virtio_transport_notify_poll_in()
to use the completed-message count (msg_count) instead of comparing queued
bytes with the SO_RCVLOWAT target. As a result, poll() and epoll no longer
report a socket readable when only part of a message has arrived.

> diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c
> index 1e762a480df49..d659986bb48b0 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;

[Severity: Medium]
This changes when poll() reports a SEQPACKET socket readable. Should the
wakeup side change as well?

For virtio, vhost and loopback, the RX wakeup comes from
virtio_transport_recv_connected() calling vsock_data_ready(). That happens
after virtio_transport_recv_enqueue() has done msg_count++ for an EOM packet.
vsock_data_ready() still uses the byte count and rcvlowat test:

net/vmw_vsock/af_vsock.c:vsock_data_ready() {
	...
	if (vsock_stream_has_data(vsk) >= sk->sk_rcvlowat ||
	    sock_flag(sk, SOCK_DONE))
		sk->sk_data_ready(sk);
}

So msg_count can go from 0 to 1, which makes poll() readable under the new
rule, without any wakeup being sent. A couple of ways this can happen:

  - Userspace sets SO_RCVLOWAT to, say, 4096 on a SEQPACKET socket and
    sleeps in poll(), select() or epoll_wait(). The peer then sends a
    complete 100 byte message. poll() with a zero timeout now returns
    EPOLLIN, but rx_bytes is 100, which is less than 4096. The sleeping
    waiter is not woken until its timeout expires, more data arrives, or
    the peer shuts down. Edge-triggered epoll never sees the transition.

  - With the default rcvlowat of 1, a peer sends a zero-length OP_RW
    packet with VIRTIO_VSOCK_SEQ_EOM into an empty queue. msg_count is
    incremented and rx_bytes stays at 0, so poll() reports readable but
    no wakeup is sent. Linux senders skip zero-length OP_RW packets in
    virtio_transport_send_pkt_info(), so this needs a non-Linux or
    modified peer.

Before this patch, poll readiness and the wakeup used the same
rx_bytes >= rcvlowat test, so they always agreed.

The commit message says:

  "SO_RCVLOWAT no longer affects SEQPACKET poll."

Isn't that only true for a non-sleeping poll? A sleeping poller is still
woken based on SO_RCVLOWAT.

Would it make sense to make vsock_data_ready() SEQPACKET-aware too? For
example, it could use the existing vsock_connectible_has_data() helper,
which already returns seqpacket_has_data() for SOCK_SEQPACKET. Another
option is to always wake for SEQPACKET once a message is complete.

> +	else
> +		*data_ready_now = vsock_stream_has_data(vsk) >= target;
>  
>  	return 0;
>  }

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202181307.73934-1-bugs%40stellman-greene.com

      parent reply	other threads:[~2026-12-03 19:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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
2026-12-03 19:10 ` netdev-bot+sashiko [this message]

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=179632505944.3146.4004115120950433578@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=bobbyeshleman@meta.com \
    --cc=bugs@stellman-greene.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=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