Skip to content

Commit a3e7b29

Browse files
peilin-yedavem330
authored andcommitted
vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout()
Imagine two non-blocking vsock_connect() requests on the same socket. The first request schedules @connect_work, and after it times out, vsock_connect_timeout() sets *sock* state back to TCP_CLOSE, but keeps *socket* state as SS_CONNECTING. Later, the second request returns -EALREADY, meaning the socket "already has a pending connection in progress", even though the first request has already timed out. As suggested by Stefano, fix it by setting *socket* state back to SS_UNCONNECTED, so that the second request will return -ETIMEDOUT. Suggested-by: Stefano Garzarella <sgarzare@redhat.com> Fixes: d021c34 ("VSOCK: Introduce VM Sockets") Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Peilin Ye <peilin.ye@bytedance.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7e97cfe commit a3e7b29

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/vmw_vsock/af_vsock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1286,6 +1286,7 @@ static void vsock_connect_timeout(struct work_struct *work)
12861286
if (sk->sk_state == TCP_SYN_SENT &&
12871287
(sk->sk_shutdown != SHUTDOWN_MASK)) {
12881288
sk->sk_state = TCP_CLOSE;
1289+
sk->sk_socket->state = SS_UNCONNECTED;
12891290
sk->sk_err = ETIMEDOUT;
12901291
sk_error_report(sk);
12911292
vsock_transport_cancel_pkt(vsk);

0 commit comments

Comments
 (0)