linux-stable/net/vmw_vsock
Sebastien Boeuf 7e29f155e8 net: virtio_vsock: Enhance connection semantics
[ Upstream commit df12eb6d6c ]

Whenever the vsock backend on the host sends a packet through the RX
queue, it expects an answer on the TX queue. Unfortunately, there is one
case where the host side will hang waiting for the answer and might
effectively never recover if no timeout mechanism was implemented.

This issue happens when the guest side starts binding to the socket,
which insert a new bound socket into the list of already bound sockets.
At this time, we expect the guest to also start listening, which will
trigger the sk_state to move from TCP_CLOSE to TCP_LISTEN. The problem
occurs if the host side queued a RX packet and triggered an interrupt
right between the end of the binding process and the beginning of the
listening process. In this specific case, the function processing the
packet virtio_transport_recv_pkt() will find a bound socket, which means
it will hit the switch statement checking for the sk_state, but the
state won't be changed into TCP_LISTEN yet, which leads the code to pick
the default statement. This default statement will only free the buffer,
while it should also respond to the host side, by sending a packet on
its TX queue.

In order to simply fix this unfortunate chain of events, it is important
that in case the default statement is entered, and because at this stage
we know the host side is waiting for an answer, we must send back a
packet containing the operation VIRTIO_VSOCK_OP_RST.

One could say that a proper timeout mechanism on the host side will be
enough to avoid the backend to hang. But the point of this patch is to
ensure the normal use case will be provided with proper responsiveness
when it comes to establishing the connection.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-14 09:51:06 +02:00
..
af_vsock.c vsock: fix timeout in vsock_accept() 2020-06-11 09:22:59 +02:00
af_vsock_tap.c VSOCK: Add vsockmon tap functions 2017-04-24 12:35:56 -04:00
hyperv_transport.c hv_sock: Remove the accept port restriction 2020-02-14 16:32:21 -05: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: add transport parameter to the virtio_transport_reset_no_sock() 2020-10-14 09:51:06 +02:00
virtio_transport_common.c net: virtio_vsock: Enhance connection semantics 2020-10-14 09:51:06 +02:00
vmci_transport.c VSOCK: use TCP state constants for sk_state 2019-08-04 09:31:59 +02:00
vmci_transport.h
vmci_transport_notify.c VSOCK: use TCP state constants for sk_state 2019-08-04 09:31:59 +02:00
vmci_transport_notify.h
vmci_transport_notify_qstate.c VSOCK: use TCP state constants for sk_state 2019-08-04 09:31:59 +02:00
vsock_addr.c