linux-stable/net/vmw_vsock
Jiyong Park 093f11b496 vsock: each transport cycles only on its own sockets
[ Upstream commit 8e6ed96376 ]

When iterating over sockets using vsock_for_each_connected_socket, make
sure that a transport filters out sockets that don't belong to the
transport.

There actually was an issue caused by this; in a nested VM
configuration, destroying the nested VM (which often involves the
closing of /dev/vhost-vsock if there was h2g connections to the nested
VM) kills not only the h2g connections, but also all existing g2h
connections to the (outmost) host which are totally unrelated.

Tested: Executed the following steps on Cuttlefish (Android running on a
VM) [1]: (1) Enter into an `adb shell` session - to have a g2h
connection inside the VM, (2) open and then close /dev/vhost-vsock by
`exec 3< /dev/vhost-vsock && exec 3<&-`, (3) observe that the adb
session is not reset.

[1] https://android.googlesource.com/device/google/cuttlefish/

Fixes: c0cfa2d8a7 ("vsock: add multi-transports support")
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jiyong Park <jiyong@google.com>
Link: https://lore.kernel.org/r/20220311020017.1509316-1-jiyong@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-23 09:16:41 +01:00
..
af_vsock.c vsock: each transport cycles only on its own sockets 2022-03-23 09:16:41 +01:00
af_vsock_tap.c
diag.c
hyperv_transport.c Drivers: hv: vmbus: Copy packets sent by Hyper-V out of the ring buffer 2021-05-14 17:37:46 +00:00
Kconfig vsock: add vsock_loopback transport 2019-12-11 15:01:23 -08:00
Makefile vsock: add vsock_loopback transport 2019-12-11 15:01:23 -08:00
virtio_transport.c vsock: each transport cycles only on its own sockets 2022-03-23 09:16:41 +01:00
virtio_transport_common.c virtio/vsock: fix the transport to work with VMADDR_CID_ANY 2021-12-22 09:32:39 +01:00
vmci_transport.c vsock: each transport cycles only on its own sockets 2022-03-23 09:16:41 +01:00
vmci_transport.h vsock: handle buffer_size sockopts in the core 2019-11-14 18:12:18 -08:00
vmci_transport_notify.c
vmci_transport_notify.h vsock: remove include/linux/vm_sockets.h file 2019-11-14 18:12:17 -08:00
vmci_transport_notify_qstate.c
vsock_addr.c vsock_addr: Check for supported flag values 2020-12-14 19:33:39 -08:00
vsock_loopback.c vsock/loopback: enable SEQPACKET for transport 2021-06-11 13:32:47 -07:00