diff options
author | Stefano Garzarella <sgarzare@redhat.com> | 2021-02-08 15:44:54 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-02-23 15:00:58 +0100 |
commit | afb1f8a1ea17cd156ee8e17ad76fb5fc3e1d332b (patch) | |
tree | 65a114346cc065244c38e23e7dae1e2b85646d5d /net | |
parent | bb7addea77224d0c6e471f6b7290f5b609416319 (diff) | |
download | linux-stable-afb1f8a1ea17cd156ee8e17ad76fb5fc3e1d332b.tar.gz linux-stable-afb1f8a1ea17cd156ee8e17ad76fb5fc3e1d332b.tar.bz2 linux-stable-afb1f8a1ea17cd156ee8e17ad76fb5fc3e1d332b.zip |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/vmw_vsock/virtio_transport_common.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c index 5f8a72d34d31..cbb336f01cf2 100644 --- a/net/vmw_vsock/virtio_transport_common.c +++ b/net/vmw_vsock/virtio_transport_common.c @@ -1033,10 +1033,10 @@ void virtio_transport_recv_pkt(struct virtio_transport *t, vsk = vsock_sk(sk); - space_available = virtio_transport_space_update(sk, pkt); - lock_sock(sk); + space_available = virtio_transport_space_update(sk, pkt); + /* Update CID in case it has changed after a transport reset event */ vsk->local_addr.svm_cid = dst.svm_cid; |