[PATCH v2 5/7] vhost: fix check on virtqueue access in in-flight getter

Maxime Coquelin maxime.coquelin at redhat.com
Fri Oct 20 10:48:02 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: 0c0935c5f794 ("vhost: allow to check in-flight packets for async vhost")
Cc: stable at dpdk.org

Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/vhost/vhost.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index ccd3c0e865..a243f88398 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -2073,9 +2073,15 @@ rte_vhost_async_get_inflight(int vid, uint16_t queue_id)
 		return ret;
 	}
 
+	if (unlikely(!vq->access_ok)) {
+		ret = -1;
+		goto out_unlock;
+	}
+
 	if (vq->async)
 		ret = vq->async->pkts_inflight_n;
 
+out_unlock:
 	rte_rwlock_write_unlock(&vq->access_lock);
 
 	return ret;
-- 
2.41.0



More information about the stable mailing list