]> git.droids-corp.org - dpdk.git/commitdiff
vhost: fix missing virtqueue lock protection
authorMaxime Coquelin <maxime.coquelin@redhat.com>
Thu, 24 Mar 2022 12:46:34 +0000 (13:46 +0100)
committerMaxime Coquelin <maxime.coquelin@redhat.com>
Mon, 9 May 2022 19:39:58 +0000 (21:39 +0200)
This patch ensures virtqueue metadata are not being
modified while rte_vhost_vring_call() is executed.

Fixes: 6c299bb7322f ("vhost: introduce vring call API")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: David Marchand <david.marchand@redhat.com>
lib/vhost/vhost.c

index cf4bac277a3dde844f374ebd7434b1123753243e..df0bb9d04372ebaa45b568abedfbafac68158982 100644 (file)
@@ -1291,11 +1291,15 @@ rte_vhost_vring_call(int vid, uint16_t vring_idx)
        if (!vq)
                return -1;
 
+       rte_spinlock_lock(&vq->access_lock);
+
        if (vq_is_packed(dev))
                vhost_vring_call_packed(dev, vq);
        else
                vhost_vring_call_split(dev, vq);
 
+       rte_spinlock_unlock(&vq->access_lock);
+
        return 0;
 }