Skip to content

Commit

Permalink
vhost: validate index in available entries API
Browse files Browse the repository at this point in the history
[ upstream commit 8c042f8 ]

This patch validates the queue index parameter, in order
to ensure neither out-of-bound accesses nor NULL pointer
dereferencing happen.

Fixes: a67f286 ("vhost: export queue free entries")

Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
mcoquelin authored and bluca committed Nov 9, 2020
1 parent 59bdbb3 commit d08a94d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/librte_vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,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);

Expand Down

0 comments on commit d08a94d

Please sign in to comment.