vsock/virtio: fix accept queue count leak on transport mismatch
Subsystems (5)
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.
--- net/vmw_vsock/virtio_transport_common.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/vmw_vsock/virtio_transport_common.c +1 -2
@@ -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)
Quoted 9 lines · Dudu Lu
virtio_transport_recv_listen()callssk_acceptq_added()beforevsock_assign_transport(). Ifvsock_assign_transport()fails or selects a different transport, the error path returns without callingsk_acceptq_removed(), permanently incrementingsk_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 byvmci_transportandhyperv_transport.Fixes c0cfa2d8a788 ("vsock: add multi-transports support")Signed-off-by Dudu Lu <[email protected]>---
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@@ -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.
Quoted 9 lines · Dudu Lu
virtio_transport_recv_listen()callssk_acceptq_added()beforevsock_assign_transport(). Ifvsock_assign_transport()fails or selects a different transport, the error path returns without callingsk_acceptq_removed(), permanently incrementingsk_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 byvmci_transportandhyperv_transport.Fixes c0cfa2d8a788 ("vsock: add multi-transports support")Signed-off-by Dudu Lu <[email protected]>---
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@@ -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)
Quoted 9 lines · Dudu Lu
virtio_transport_recv_listen()callssk_acceptq_added()beforevsock_assign_transport(). Ifvsock_assign_transport()fails or selects a different transport, the error path returns without callingsk_acceptq_removed(), permanently incrementingsk_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 byvmci_transportandhyperv_transport.Fixes c0cfa2d8a788 ("vsock: add multi-transports support")Signed-off-by Dudu Lu <[email protected]>---
net/vmw_vsock/virtio_transport_common.c| 3 +--1 file changed, 1 insertion(+), 2 deletions(-)
Quoted 6 lines · Dudu Lu
virtio_transport_recv_listen()callssk_acceptq_added()beforevsock_assign_transport(). Ifvsock_assign_transport()fails or selects a different transport, the error path returns without callingsk_acceptq_removed(), permanently incrementingsk_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 byvmci_transportandhyperv_transport.Fixes c0cfa2d8a788 ("vsock: add multi-transports support")Signed-off-by Dudu Lu <[email protected]>
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@@ -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 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()callssk_acceptq_added()beforevsock_assign_transport(). Ifvsock_assign_transport()fails or selects a different transport, the error path returns without callingsk_acceptq_removed(), permanently incrementingsk_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