hv_sock: add locking in the open/close/release code paths
authorDexuan Cui <decui@microsoft.com>
Thu, 19 Oct 2017 03:33:14 +0000 (03:33 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sat, 21 Oct 2017 01:21:08 +0000 (02:21 +0100)
commitb4562ca7925a3bedada87a3dd072dd5bad043288
tree09617e8799fad7a018b8d4548d8181034c54266c
parent0a90e251988ceedc528c8db98f25b051cf190f44
hv_sock: add locking in the open/close/release code paths

Without the patch, when hvs_open_connection() hasn't completely established
a connection (e.g. it has changed sk->sk_state to SS_CONNECTED, but hasn't
inserted the sock into the connected queue), vsock_stream_connect() may see
the sk_state change and return the connection to the userspace, and next
when the userspace closes the connection quickly, hvs_release() may not see
the connection in the connected queue; finally hvs_open_connection()
inserts the connection into the queue, but we won't be able to purge the
connection for ever.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Stephen Hemminger <sthemmin@microsoft.com>
Cc: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: Cathy Avery <cavery@redhat.com>
Cc: Rolf Neugebauer <rolf.neugebauer@docker.com>
Cc: Marcelo Cerri <marcelo.cerri@canonical.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/hyperv_transport.c