From 8c042f8191f8337da30958d0f622776861e417a5 Mon Sep 17 00:00:00 2001 From: Maxime Coquelin Date: Mon, 19 Oct 2020 19:34:10 +0200 Subject: [PATCH] vhost: validate index in available entries API This patch validates the queue index parameter, in order to ensure neither out-of-bound accesses nor NULL pointer dereferencing happen. Fixes: a67f286a6596 ("vhost: export queue free entries") Cc: stable@dpdk.org Signed-off-by: Maxime Coquelin Reviewed-by: Chenbo Xia --- lib/librte_vhost/vhost.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c index 0c9ba3b3af..193dafc369 100644 --- a/lib/librte_vhost/vhost.c +++ b/lib/librte_vhost/vhost.c @@ -1260,7 +1260,12 @@ rte_vhost_avail_entries(int vid, uint16_t queue_id) if (!dev) return 0; + if (queue_id >= VHOST_MAX_VRING) + return 0; + vq = dev->virtqueue[queue_id]; + if (!vq) + return 0; rte_spinlock_lock(&vq->access_lock); -- 2.20.1