]> git.baikalelectronics.ru Git - kernel.git/commit
vsock: each transport cycles only on its own sockets
authorJiyong Park <jiyong@google.com>
Fri, 11 Mar 2022 02:00:16 +0000 (11:00 +0900)
committerJakub Kicinski <kuba@kernel.org>
Sat, 12 Mar 2022 07:14:19 +0000 (23:14 -0800)
commit00649153cc91089e1c780fd4b9f964d71b1b8a9c
tree1377199816728c9c6f85aa239261b055f80159d1
parentae79bd00fcc1b8857c6b4d3315e924b7ce722f67
vsock: each transport cycles only on its own sockets

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: e29ab509ea9a ("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>
drivers/vhost/vsock.c
include/net/af_vsock.h
net/vmw_vsock/af_vsock.c
net/vmw_vsock/virtio_transport.c
net/vmw_vsock/vmci_transport.c