[PATCH net v3 8/8] vsock: enforce no-transport invariant for TCP_LISTEN sockets

From: Michal Luczaj

Date: Tue Sep 22 2026 - 09:28:07 EST


In the past, listener socket could carry an assigned transport (uselessly,
but harmlessly, except for unnecessarily hogging the kernel module refcnt).
That's not the case anymore. Express/enforce the invariant.

Signed-off-by: Michal Luczaj <mhal@xxxxxxx>
---
net/vmw_vsock/af_vsock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 56c595942456..9ba21a448cfa 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1993,13 +1993,13 @@ static int vsock_listen(struct socket *sock, int backlog)
goto out;
}

- if (sock->state != SS_UNCONNECTED) {
+ vsk = vsock_sk(sk);
+
+ if (sock->state != SS_UNCONNECTED || WARN_ON_ONCE(vsk->transport)) {
err = -EINVAL;
goto out;
}

- vsk = vsock_sk(sk);
-
if (!vsock_addr_bound(&vsk->local_addr)) {
err = -EINVAL;
goto out;

--
2.55.0