vsock/virtio: update credit only if socket is not closed
authorStefano Garzarella <sgarzare@redhat.com>
Mon, 8 Feb 2021 14:44:54 +0000 (15:44 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Feb 2021 10:02:29 +0000 (11:02 +0100)
commitafe31701609b6ccf5cc637fb229383c26d72d478
tree8aa40544c32befccfad0f55ea6510fc297815ce6
parentba3bcb35d783805f2b3ebf2ebf61702cd68f4959
vsock/virtio: update credit only if socket is not closed

commit ce7536bc7398e2ae552d2fabb7e0e371a9f1fe46 upstream.

If the socket is closed or is being released, some resources used by
virtio_transport_space_update() such as 'vsk->trans' may be released.

To avoid a use after free bug we should only update the available credit
when we are sure the socket is still open and we have the lock held.

Fixes: 06a8fc78367d ("VSOCK: Introduce virtio_vsock_common.ko")
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Link: https://lore.kernel.org/r/20210208144454.84438-1-sgarzare@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/vmw_vsock/virtio_transport_common.c