hw/virtio: Acquire RCU read lock in virtqueue_packed_drop_all()
authorPhilippe Mathieu-Daudé <philmd@redhat.com>
Mon, 6 Sep 2021 10:43:17 +0000 (12:43 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Tue, 5 Oct 2021 15:19:40 +0000 (11:19 -0400)
vring_get_region_caches() must be called with the RCU read lock
acquired. virtqueue_packed_drop_all() does not, and uses the
'caches' pointer. Fix that by using the RCU_READ_LOCK_GUARD()
macro.

Reported-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20210906104318.1569967-3-philmd@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
hw/virtio/virtio.c

index 240759ff0b7b61c868e6cacf5ed455cabba943fd..dd0ab433b8776094249785b93aa8c1c6d2ba6b51 100644 (file)
@@ -1703,6 +1703,8 @@ static unsigned int virtqueue_packed_drop_all(VirtQueue *vq)
     VirtIODevice *vdev = vq->vdev;
     VRingPackedDesc desc;
 
+    RCU_READ_LOCK_GUARD();
+
     caches = vring_get_region_caches(vq);
     if (!caches) {
         return 0;