Commit afbea2cd authored by Jorgen Hansen's avatar Jorgen Hansen Committed by David S. Miller

VSOCK: Don't call vsock_stream_has_data in atomic context

When using the host personality, VMCI will grab a mutex for any
queue pair access. In the detach callback for the vmci vsock
transport, we call vsock_stream_has_data while holding a spinlock,
and vsock_stream_has_data will access a queue pair.

To avoid this, we can simply omit calling vsock_stream_has_data
for host side queue pairs, since the QPs are empty per default
when the guest has detached.

This bug affects users of VMware Workstation using kernel version
4.4 and later.

Testing: Ran vsock tests between guest and host, and verified that
with this change, the host isn't calling vsock_stream_has_data
during detach. Ran mixedTest between guest and host using both
guest and host as server.

v2: Rebased on top of recent change to sk_state values
Reviewed-by: default avatarAdit Ranadive <aditr@vmware.com>
Reviewed-by: default avatarAditya Sarwade <asarwade@vmware.com>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarJorgen Hansen <jhansen@vmware.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a60b3f51
...@@ -797,9 +797,13 @@ static void vmci_transport_handle_detach(struct sock *sk) ...@@ -797,9 +797,13 @@ static void vmci_transport_handle_detach(struct sock *sk)
/* We should not be sending anymore since the peer won't be /* We should not be sending anymore since the peer won't be
* there to receive, but we can still receive if there is data * there to receive, but we can still receive if there is data
* left in our consume queue. * left in our consume queue. If the local endpoint is a host,
* we can't call vsock_stream_has_data, since that may block,
* but a host endpoint can't read data once the VM has
* detached, so there is no available data in that case.
*/ */
if (vsock_stream_has_data(vsk) <= 0) { if (vsk->local_addr.svm_cid == VMADDR_CID_HOST ||
vsock_stream_has_data(vsk) <= 0) {
sk->sk_state = TCP_CLOSE; sk->sk_state = TCP_CLOSE;
if (sk->sk_state == TCP_SYN_SENT) { if (sk->sk_state == TCP_SYN_SENT) {
...@@ -2144,7 +2148,7 @@ module_exit(vmci_transport_exit); ...@@ -2144,7 +2148,7 @@ module_exit(vmci_transport_exit);
MODULE_AUTHOR("VMware, Inc."); MODULE_AUTHOR("VMware, Inc.");
MODULE_DESCRIPTION("VMCI transport for Virtual Sockets"); MODULE_DESCRIPTION("VMCI transport for Virtual Sockets");
MODULE_VERSION("1.0.4.0-k"); MODULE_VERSION("1.0.5.0-k");
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
MODULE_ALIAS("vmware_vsock"); MODULE_ALIAS("vmware_vsock");
MODULE_ALIAS_NETPROTO(PF_VSOCK); MODULE_ALIAS_NETPROTO(PF_VSOCK);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment