From: Jerome Mohm 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 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 --- 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