[PATCH v2 4/7] vhost: fix check on virtqueue access in async registration
Maxime Coquelin
maxime.coquelin at redhat.com
Fri Oct 20 10:48:01 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: 78639d54563a ("vhost: introduce async enqueue registration API")
Cc: stable at dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
lib/vhost/vhost.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 5428ff4a25..ccd3c0e865 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -1857,7 +1857,15 @@ rte_vhost_async_channel_register(int vid, uint16_t queue_id)
return -1;
rte_rwlock_write_lock(&vq->access_lock);
+
+ if (unlikely(!vq->access_ok)) {
+ ret = -1;
+ goto out_unlock;
+ }
+
ret = async_channel_register(dev, vq);
+
+out_unlock:
rte_rwlock_write_unlock(&vq->access_lock);
return ret;
@@ -1909,6 +1917,11 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
return ret;
}
+ if (unlikely(!vq->access_ok)) {
+ ret = -1;
+ goto out_unlock;
+ }
+
if (!vq->async) {
ret = 0;
} else if (vq->async->pkts_inflight_n) {
@@ -1920,6 +1933,7 @@ rte_vhost_async_channel_unregister(int vid, uint16_t queue_id)
ret = 0;
}
+out_unlock:
rte_rwlock_write_unlock(&vq->access_lock);
return ret;
--
2.41.0
More information about the dev
mailing list