]> git.baikalelectronics.ru Git - kernel.git/commit
vsock: fix locking in vsock_shutdown()
authorStefano Garzarella <sgarzare@redhat.com>
Tue, 9 Feb 2021 08:52:19 +0000 (09:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Feb 2021 23:31:22 +0000 (15:31 -0800)
commit5b3986ff7291f3d750903ca3e99b97859630fc87
tree338dfb4c5f7f0dc46ddfb3aa6f5372c63d1faaa2
parent98cf4b9d1f4fdf0f5515f2311aa60fc39248c2a5
vsock: fix locking in vsock_shutdown()

In vsock_shutdown() we touched some socket fields without holding the
socket lock, such as 'state' and 'sk_flags'.

Also, after the introduction of multi-transport, we are accessing
'vsk->transport' in vsock_send_shutdown() without holding the lock
and this call can be made while the connection is in progress, so
the transport can change in the meantime.

To avoid issues, we hold the socket lock when we enter in
vsock_shutdown() and release it when we leave.

Among the transports that implement the 'shutdown' callback, only
hyperv_transport acquired the lock. Since the caller now holds it,
we no longer take it.

Fixes: 031acdb8ab77 ("VSOCK: Introduce VM Sockets")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/vmw_vsock/af_vsock.c
net/vmw_vsock/hyperv_transport.c