linux-stable/net/vmw_vsock
Peilin Ye 9035d5912c vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout()
commit a3e7b29e30 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: d021c34405 ("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>
2022-08-25 11:11:33 +02:00
..
af_vsock.c vsock: Set socket state back to SS_UNCONNECTED in vsock_connect_timeout() 2022-08-25 11:11:33 +02:00
af_vsock_tap.c VSOCK: Add vsockmon tap functions 2017-04-24 12:35:56 -04:00
hyperv_transport.c vsock: fix locking in vsock_shutdown() 2021-02-23 14:00:33 +01:00
Kconfig hv_sock: implements Hyper-V transport for Virtual Sockets (AF_VSOCK) 2017-08-28 15:38:18 -07:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
virtio_transport.c vsock/virtio: avoid potential deadlock when vsock device remove 2021-08-26 08:37:02 -04:00
virtio_transport_common.c vsock/virtio: update credit only if socket is not closed 2021-02-23 14:00:32 +01:00
vmci_transport.c vsock/vmci: log once the failed queue pair allocation 2021-05-22 10:57:34 +02:00
vmci_transport.h VSOCK: constify vmci_transport_notify_ops structures 2015-11-23 15:49:29 -05:00
vmci_transport_notify.c VSOCK: use TCP state constants for sk_state 2019-08-04 09:31:59 +02:00
vmci_transport_notify.h VSOCK: constify vmci_transport_notify_ops structures 2015-11-23 15:49:29 -05:00
vmci_transport_notify_qstate.c VSOCK: use TCP state constants for sk_state 2019-08-04 09:31:59 +02:00
vsock_addr.c