Netdev List
 help / color / mirror / Atom feed
* [PATCH] vsock/hv_sock: reject incoming connections when the listener is being released
@ 2026-09-17 22:01 Bartłomiej Dmitruk
  2026-09-18 13:17 ` Stefano Garzarella
  2026-09-21 23:17 ` netdev-bot+sashiko
  0 siblings, 2 replies; 3+ messages in thread
From: Bartłomiej Dmitruk @ 2026-09-17 22:01 UTC (permalink / raw)
  To: Dexuan Cui, Wei Liu, Haiyang Zhang, K . Y . Srinivasan
  Cc: linux-hyperv, netdev, Stefano Garzarella, Michael S . Tsirkin

hvs_open_connection() only checks sk_state == TCP_LISTEN and
sk_acceptq_is_full() before creating a child and calling
vsock_enqueue_accept().  __vsock_release() sets sk->sk_shutdown =
SHUTDOWN_MASK and flushes the accept queue while leaving sk_state ==
TCP_LISTEN, so a host channel offer that races close() of the listener
passes both checks and enqueues a child onto the already-flushed queue.
That child socket (and the VMBUS channel opened for it) is never accepted
or cleaned up and leaks.

The virtio transport guards exactly this case in
virtio_transport_recv_listen(); hv_sock lacks the equivalent guard.
hv_sock holds lock_sock(sk) across hvs_open_connection(), so the check is
race-free.

Signed-off-by: Bartłomiej Dmitruk <bartlomiej.dmitruk@isec.pl>
---
diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c
--- a/net/vmw_vsock/hyperv_transport.c
+++ b/net/vmw_vsock/hyperv_transport.c
@@ -324,6 +324,14 @@
 
 	if (conn_from_host) {
 		if (sk_acceptq_is_full(sk))
+			goto out;
+
+		/* __vsock_release() may have already flushed the accept queue
+		 * and set sk_shutdown = SHUTDOWN_MASK while leaving sk_state ==
+		 * TCP_LISTEN.  Enqueuing a child now would leak the child socket
+		 * and its VMBUS channel.  Mirror virtio_transport_recv_listen().
+		 */
+		if (sk->sk_shutdown == SHUTDOWN_MASK)
 			goto out;
 
 		new = vsock_create_connected(sk);

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

end of thread, other threads:[~2026-09-21 23:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 22:01 [PATCH] vsock/hv_sock: reject incoming connections when the listener is being released Bartłomiej Dmitruk
2026-09-18 13:17 ` Stefano Garzarella
2026-09-21 23:17 ` netdev-bot+sashiko

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