From 78414da84eb5f5ae3594a073bdc978d3e14efeb4 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Thu, 24 Mar 2022 13:46:34 +0100 Subject: [PATCH] vhost: fix missing virtqueue lock protection [ upstream commit c5736998305def298e26f8fa73b9995f184fc983 ] This patch ensures virtqueue metadata are not being modified while rte_vhost_vring_call() is executed. Fixes: 6c299bb7322f ("vhost: introduce vring call API") Signed-off-by: Maxime Coquelin Reviewed-by: David Marchand --- lib/vhost/vhost.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index 13a9bb9dd1..474645b64e 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1299,11 +1299,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; }