[PATCH v2 3/7] vhost: fix checking virtqueue access when notifying guest
Maxime Coquelin
maxime.coquelin at redhat.com
Fri Oct 20 10:48:00 CEST 2023
Acquiring the access lock is not enough to ensure
virtqueue's metadata such as vring pointers are valid.
The access status must also be checked.
Fixes: d761d455a0e4 ("vhost: add operation to offload the interrupt kick")
Cc: stable at dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
lib/vhost/vhost.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 446bca1574..5428ff4a25 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1542,6 +1542,9 @@ rte_vhost_notify_guest(int vid, uint16_t queue_id)
rte_rwlock_read_lock(&vq->access_lock);
+ if (unlikely(!vq->access_ok))
+ goto out_unlock;
+
__atomic_store_n(&vq->irq_pending, false, __ATOMIC_RELEASE);
if (dev->backend_ops->inject_irq(dev, vq)) {
@@ -1556,6 +1559,7 @@ rte_vhost_notify_guest(int vid, uint16_t queue_id)
dev->notify_ops->guest_notified(dev->vid);
}
+out_unlock:
rte_rwlock_read_unlock(&vq->access_lock);
}
--
2.41.0
More information about the dev
mailing list