Netdev List
 help / color / mirror / Atom feed
* [PATCH net] vsock/bpf: do not count psock->ingress_skb as data to read
@ 2026-12-01  8:32 Jerome Mohm via B4 Relay
  2026-12-02  1:36 ` Bobby Eshleman
  0 siblings, 1 reply; 2+ messages in thread
From: Jerome Mohm via B4 Relay @ 2026-12-01  8:32 UTC (permalink / raw)
  To: Stefano Garzarella, Bobby Eshleman, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Willem de Bruijn, Simon Horman,
	Michael S. Tsirkin, Alexei Starovoitov
  Cc: Michal Luczaj, linux-kernel, virtualization, netdev, bpf, Sashiko,
	stable, Jerome Mohm

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>



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

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

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  8:32 [PATCH net] vsock/bpf: do not count psock->ingress_skb as data to read Jerome Mohm via B4 Relay
2026-12-02  1:36 ` Bobby Eshleman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox