From: Bobby Eshleman <bobbyeshleman@meta.com>
To: <jrmmhm.kernel@eldare.de>
Cc: Stefano Garzarella <sgarzare@redhat.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>,
"Michael S. Tsirkin" <mst@redhat.com>,
Alexei Starovoitov <ast@kernel.org>, Michal Luczaj <mhal@rbox.co>,
<linux-kernel@vger.kernel.org>, <virtualization@lists.linux.dev>,
<netdev@vger.kernel.org>, <bpf@vger.kernel.org>,
Sashiko <sashiko-bot@kernel.org>, <stable@vger.kernel.org>
Subject: Re: [PATCH net] vsock/bpf: do not count psock->ingress_skb as data to read
Date: Tue, 1 Dec 2026 17:36:24 -0800 [thread overview]
Message-ID: <aw92GP5n9ydBzM8x@devvm29614.prn0.facebook.com> (raw)
In-Reply-To: <20261201-kup7-ingress-skb-send-v1-1-54ae8d4bf0a7@eldare.de>
On Tue, Dec 01, 2026 at 09:32:33AM +0100, Jerome Mohm via B4 Relay wrote:
> From: Jerome Mohm <jrmmhm.kernel@eldare.de>
>
> A blocking recv() on a vsock socket in a sockmap can keep sleeping
> after its data has become readable, until its timeout or a signal.
>
> vsock_sk_has_data() counts skbs in psock->ingress_skb, which recvmsg
> cannot read. With skbs only there, vsock_bpf_recvmsg() falls back to
> __vsock_recvmsg(), which waits for transport data and never looks at
> ingress_msg, where a verdict program puts the data. This happens when
> the socket is the target of an egress redirect and its peer does not
> read: the socket's own data queues behind the redirected skbs.
>
> Do not count ingress_skb (tcp_bpf does not either), so the reader
> stays in vsock_msg_wait_data() until the backlog has moved the data to
> ingress_msg. Before the prerequisite named in the stable tag that wait
> held the socket lock, so this must not be backported without it.
>
> One behaviour change, read in the code and not run: a stream read of
> at least the buffer size with MSG_WAITALL (or with SO_RCVLOWAT that
> high) got -ENOMEM at once while skbs sat only in ingress_skb. It now
> waits for data, as it already does when ingress_skb is empty.
>
> Found by the netdev Sashiko review of an earlier patch to this file.
> A way to trigger it, an egress redirect to a socket whose peer does
> not read, was found with the help of Anthropic's Claude. Reproduced on
> an unmodified kernel in a VM over vsock loopback, with stream and
> seqpacket sockets: the reader got -EAGAIN when its SO_RCVTIMEO ran out
> with its data queued. With the fix it gets the data. The vsock
> vmtest.sh single-VM tests and the BPF sockmap_basic, sockmap_listen
> and sockmap_redir tests pass but do not reach this case. I did not run
> this case over the virtio transport and did not test a tree without
> that prerequisite.
>
> Fixes: 634f1a7110b4 ("vsock: support sockmap")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Closes: https://lore.kernel.org/netdev/179123556339.434549.8635789838298158117@kernel.org/
> Cc: stable@vger.kernel.org # cfd56c8720f8: vsock/bpf: release sock lock while waiting for data in recvmsg
> Signed-off-by: Jerome Mohm <jrmmhm.kernel@eldare.de>
> ---
> The review named an ingress redirect as the way into ingress_skb. For
> vsock that returns SK_DROP since commit 9c5bd93edf7b ("bpf, sockmap:
> SK_DROP on attempted redirects of unsupported af_vsock"); hence the
> egress redirect above.
>
> Also run: with skbs in ingress_skb the read still ends on timeout,
> signal, shutdown and socket error. The test programs are available
> on request.
> ---
> net/vmw_vsock/vsock_bpf.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/net/vmw_vsock/vsock_bpf.c b/net/vmw_vsock/vsock_bpf.c
> index 41307759da99..c1bc4ed04680 100644
> --- a/net/vmw_vsock/vsock_bpf.c
> +++ b/net/vmw_vsock/vsock_bpf.c
> @@ -14,7 +14,6 @@
>
> #define vsock_sk_has_data(__sk, __psock) \
> ({ !skb_queue_empty(&(__sk)->sk_receive_queue) || \
> - !skb_queue_empty(&(__psock)->ingress_skb) || \
> !list_empty(&(__psock)->ingress_msg); \
> })
>
>
> ---
> base-commit: 656683f2e292a8ab28b1863a9a8aa0f9417b58a5
> change-id: 20261201-kup7-ingress-skb-send-2a76d115d76b
>
> Best regards,
> --
> Jerome Mohm <jrmmhm.kernel@eldare.de>
I remember modeling this after unix (and I think udp?) which seems to
still use ingress_skb too. I wonder if the issue exists there too?
Anyway, definitely not right for vsock. Thanks for the fix!
Reviewed-by: Bobby Eshleman <bobbyeshleman@meta.com>
prev parent reply other threads:[~2026-12-02 1:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 8:32 [PATCH net] vsock/bpf: do not count psock->ingress_skb as data to read Jerome Mohm
2026-12-01 8:32 ` Jerome Mohm via B4 Relay
2026-12-01 8:38 ` sashiko-bot
2026-12-02 1:36 ` Bobby Eshleman [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=aw92GP5n9ydBzM8x@devvm29614.prn0.facebook.com \
--to=bobbyeshleman@meta.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jrmmhm.kernel@eldare.de \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mhal@rbox.co \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sashiko-bot@kernel.org \
--cc=sgarzare@redhat.com \
--cc=stable@vger.kernel.org \
--cc=virtualization@lists.linux.dev \
--cc=willemb@google.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 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.