Skip to content

Commit 4b5f1ad

Browse files
stefano-garzarellakuba-moo
authored andcommitted
vsock/virtio: initialize vdev->priv before using VQs
When we fill VQs with empty buffers and kick the host, it may send an interrupt. `vdev->priv` must be initialized before this since it is used in the virtqueue callbacks. Fixes: 0deab08 ("vsock/virtio: use RCU to avoid use-after-free on the_virtio_vsock") Suggested-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9fe087d commit 4b5f1ad

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

net/vmw_vsock/virtio_transport.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
622622
INIT_WORK(&vsock->event_work, virtio_transport_event_work);
623623
INIT_WORK(&vsock->send_pkt_work, virtio_transport_send_pkt_work);
624624

625+
vdev->priv = vsock;
626+
625627
mutex_lock(&vsock->tx_lock);
626628
vsock->tx_run = true;
627629
mutex_unlock(&vsock->tx_lock);
@@ -639,7 +641,6 @@ static int virtio_vsock_probe(struct virtio_device *vdev)
639641
if (virtio_has_feature(vdev, VIRTIO_VSOCK_F_SEQPACKET))
640642
vsock->seqpacket_allow = true;
641643

642-
vdev->priv = vsock;
643644
rcu_assign_pointer(the_virtio_vsock, vsock);
644645

645646
mutex_unlock(&the_virtio_vsock_mutex);

0 commit comments

Comments
 (0)