vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout()
authorPeilin Ye <peilin.ye@bytedance.com>
Mon, 8 Aug 2022 18:05:25 +0000 (11:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Aug 2022 09:11:33 +0000 (11:11 +0200)
commit9035d5912cec89f68b8921fd5a801c169613decf
tree3d0933e96d1a8ca303a6d444ddcf6d72c44d46e5
parentec0a5b730cc053202df6b6e6dd6c860977990646
vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout()

commit a3e7b29e30854ed67be0d17687e744ad0c769c4b upstream.

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: d021c344051a ("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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/vmw_vsock/af_vsock.c