[PATCH 3/7] vhost: fix checking virtqueue access when notifying guest
Maxime Coquelin
maxime.coquelin at redhat.com
Mon Sep 25 18:36:06 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 83b71ffb23..f07674334d 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1540,6 +1540,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;
+
if (dev->backend_ops->inject_irq(dev, vq)) {
if (dev->flags & VIRTIO_DEV_STATS_ENABLED)
__atomic_fetch_add(&vq->stats.guest_notifications_error,
@@ -1552,6 +1555,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 stable
mailing list