Re: [PATCH net-next v6 1/8] vsock: only undo SS_CONNECTING when connect() fails
From: Michal Luczaj
Date: Sun Nov 15 2026 - 18:11:07 EST
On 11/14/26 04:14, Bobby Eshleman wrote:
> vsock_connect() sleeps with the socket unlocked. Meanwhile the transport
> can complete the handshake, setting sock->state to SS_CONNECTED, and then
> reset the connection, e.g. in vhost_vsock_reset_orphans(),
> virtio_vsock_reset_sock() or vmci_transport_handle_detach(). When
> connect() gets the lock back, it finds sk_err set and moves the socket
> back to SS_UNCONNECTED. Userspace can then connect() the socket again,
> and a connect() to a CID on another transport makes
> vsock_assign_transport() release the transport the socket was connected
> on.
>
> Only move the socket back to SS_UNCONNECTED if it is still
> SS_CONNECTING. A socket that got connected stays SS_CONNECTED, and
> another connect() fails with -EISCONN.
>
> Fixes: d021c344051a ("VSOCK: Introduce VM Sockets")
> Suggested-by: Michal Luczaj <mhal@xxxxxxx>
> Link: https://lore.kernel.org/netdev/179447093204.2199510.8895677421994612994@xxxxxxxxxx/
> Signed-off-by: Bobby Eshleman <bobbyeshleman@xxxxxxxx>
Reviewed-by: Michal Luczaj <mhal@xxxxxxx>
Thanks! To be precise, the Link: above is more of Sashiko's musings on
what's wrong with Jerome's (not merged) patch. The patch of yours makes it
moot.
I believe the first time lore mentions the issue at hand:
Link:
https://lore.kernel.org/netdev/20260909-vsock-connect-reset-closing-v1-1-50298b9ccfbf@xxxxxxx/
And there was at least one report off-list, so:
Reported-by: Kyle Zeng <kylebot@xxxxxxxxxx>
BTW, I've noticed Sashiko already commented on this patch. I feel I'm
responsible for that wall of text, so I took the liberty to reply. Hope
this will help.