Skip to contentSkip to conversation

vsock/virtio: fix accept queue count leak on transport mismatch

PATCH Applied Dudu Lu 6 participants 6 messages Apr 13 – Apr 16

Subsystems (5)
lore
Share & tools
lore

Dudu Lu

author
#0 lore raw

PATCH v2 1/1 vsock/virtio: fix accept queue count leak on transport mismatch

virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.

After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.

Fix by moving sk_acceptq_added() to after the transport validation, matching the pattern used by vmci_transport and hyperv_transport.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")
---
 net/vmw_vsock/virtio_transport_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +1 -2
index 8a9fb23c6e85..e01d983488e5 100644
@@ -1560,8 +1560,6 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return -ENOMEM;
 	}
 
-	sk_acceptq_added(sk);
-
 	lock_sock_nested(child, SINGLE_DEPTH_NESTING);
 
 	child->sk_state = TCP_ESTABLISHED;
@@ -1583,6 +1581,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return ret;
 	}
 
+	sk_acceptq_added(sk);
 	if (virtio_transport_space_update(child, skb))
 		child->sk_write_space(child);
 
Signature · 1 line
2.39.3 (Apple Git-145)
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Dudu Lu

virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.

After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.

Quoted 6 lines

Fix by moving sk_acceptq_added() to after the transport validation, matching the pattern used by vmci_transport and hyperv_transport.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")

---

Just a heads up that version change lists are encouraged.

Quoted 27 lines
 net/vmw_vsock/virtio_transport_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +1 -2
index 8a9fb23c6e85..e01d983488e5 100644
@@ -1560,8 +1560,6 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return -ENOMEM;
 	}
 
-	sk_acceptq_added(sk);
-
 	lock_sock_nested(child, SINGLE_DEPTH_NESTING);
 
 	child->sk_state = TCP_ESTABLISHED;
@@ -1583,6 +1581,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return ret;
 	}
 
+	sk_acceptq_added(sk);
 	if (virtio_transport_space_update(child, skb))
 		child->sk_write_space(child);
 
Signature · 1 line
2.39.3 (Apple Git-145)

This makes sense to me.

Reviewed-by on v2 1/1
#2 lore raw
In reply to Dudu Lu
Quoted 9 lines · Dudu Lu

virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.

After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.

Quoted 6 lines

Fix by moving sk_acceptq_added() to after the transport validation, matching the pattern used by vmci_transport and hyperv_transport.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")

---

You forgot to add the net tag to the patch.

Other than that, the code LGTM and testing passed.

Quoted 27 lines

net/vmw_vsock/virtio_transport_common.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +1 -2
index 8a9fb23c6e85..e01d983488e5 100644
@@ -1560,8 +1560,6 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return -ENOMEM;
 	}
 
-	sk_acceptq_added(sk);
-
 	lock_sock_nested(child, SINGLE_DEPTH_NESTING);
 
 	child->sk_state = TCP_ESTABLISHED;
@@ -1583,6 +1581,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return ret;
 	}
 
+	sk_acceptq_added(sk);
 	if (virtio_transport_space_update(child, skb))
 		child->sk_write_space(child);
 
Signature · 1 line
2.39.3 (Apple Git-145)
maintainer Reviewed-by on v2 1/1
#3 lore raw
In reply to Dudu Lu
Quoted 9 lines · Dudu Lu

virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.

After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.

Quoted 8 lines

Fix by moving sk_acceptq_added() to after the transport validation, matching the pattern used by vmci_transport and hyperv_transport.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")

---
net/vmw_vsock/virtio_transport_common.c | 3 +--

1 file changed, 1 insertion(+), 2 deletions(-)
maintainer Acked-by on v2 1/1
#4 lore raw
In reply to Dudu Lu
Quoted 6 lines · Dudu Lu

virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.

Quoted 8 lines

After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.

Fix by moving sk_acceptq_added() to after the transport validation, matching the pattern used by vmci_transport and hyperv_transport.

Fixes c0cfa2d8a788 ("vsock: add multi-transports support")
Quoted 27 lines
---
 net/vmw_vsock/virtio_transport_common.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +1 -2
index 8a9fb23c6e85..e01d983488e5 100644
@@ -1560,8 +1560,6 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return -ENOMEM;
 	}
 
-	sk_acceptq_added(sk);
-
 	lock_sock_nested(child, SINGLE_DEPTH_NESTING);
 
 	child->sk_state = TCP_ESTABLISHED;
@@ -1583,6 +1581,7 @@ virtio_transport_recv_listen(struct sock *sk, struct sk_buff *skb,
 		return ret;
 	}
 
+	sk_acceptq_added(sk);
 	if (virtio_transport_space_update(child, skb))
 		child->sk_write_space(child);
 
Signature · 1 line
2.39.3 (Apple Git-145)
#5 lore raw
In reply to Dudu Lu
This patch was applied to netdev/net.git (main) by Paolo Abeni <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Mon, 13 Apr 2026 21:14:09 +0800 you wrote:

virtio_transport_recv_listen() calls sk_acceptq_added() before vsock_assign_transport(). If vsock_assign_transport() fails or selects a different transport, the error path returns without calling sk_acceptq_removed(), permanently incrementing sk_ack_backlog.

After approximately backlog+1 such failures, sk_acceptq_is_full() returns true, causing the listener to reject all new connections.

[...]

Here is the summary with links:
- [v2] vsock/virtio: fix accept queue count leak on transport mismatch

    https://git.kernel.org/netdev/net/c/52bcb57a4e8a

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html