mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 19:08:57 +09:00
vsock/virtio: update credit only if socket is not closed
commitce7536bc73upstream. 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:06a8fc7836("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>
This commit is contained in:
committed by
Chris
parent
f6f940663c
commit
45ff09fb10
@@ -959,10 +959,10 @@ void virtio_transport_recv_pkt(struct virtio_vsock_pkt *pkt)
|
||||
|
||||
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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user