]> git.baikalelectronics.ru Git - kernel.git/commit
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)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 Aug 2022 08:50:18 +0000 (09:50 +0100)
commita722cf48d6af05e41bcb34faf8766b040b4928bb
tree2dc887bf6b130804f3bbbba6136f0a8cc6ca52cb
parentfbfe820c7ba970951e50c6c0d737de4f67881a32
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: e9d736dd26b5 ("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>
net/vmw_vsock/af_vsock.c