From: Stefano Garzarella <sgarzare@redhat.com>
To: "Bartłomiej Dmitruk" <bartlomiej.dmitruk@isec.pl>
Cc: Dexuan Cui <decui@microsoft.com>, Wei Liu <wei.liu@kernel.org>,
Haiyang Zhang <haiyangz@microsoft.com>,
"K . Y . Srinivasan" <kys@microsoft.com>,
linux-hyperv@vger.kernel.org, netdev@vger.kernel.org,
"Michael S . Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH] vsock/hv_sock: reject incoming connections when the listener is being released
Date: Fri, 18 Sep 2026 15:17:33 +0200 [thread overview]
Message-ID: <aq05eT6CP9ns6Cae@sgarzare-redhat> (raw)
In-Reply-To: <20260917220156.56015-1-bartlomiej.dmitruk@isec.pl>
On Fri, Sep 18, 2026 at 12:01:54AM +0200, Bartłomiej Dmitruk wrote:
>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.
>
Fixes tag missing.
>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;
Should we do this check also if conn_from_host is false?
If it's the case, I guess we can add that check in the checks we do
after lock_sock().
Thanks,
Stefano
>
> new = vsock_create_connected(sk);
>
next prev parent reply other threads:[~2026-09-18 13:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-09-21 23:17 ` netdev-bot+sashiko
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=aq05eT6CP9ns6Cae@sgarzare-redhat \
--to=sgarzare@redhat.com \
--cc=bartlomiej.dmitruk@isec.pl \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=wei.liu@kernel.org \
/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