Skip to content

Commit

Permalink
vhost: validate index in live-migration API
Browse files Browse the repository at this point in the history
[ upstream commit 943daec ]

This patch validates the queue index parameter, in order
to ensure no out-of-bound accesses happen.

Fixes: bd2e0c3 ("vhost: add APIs for live migration")

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 ed20f3a commit 215263f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/librte_vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,9 @@ int rte_vhost_get_vring_base(int vid, uint16_t queue_id,
if (dev == NULL || last_avail_idx == NULL || last_used_idx == NULL)
return -1;

if (queue_id >= VHOST_MAX_VRING)
return -1;

vq = dev->virtqueue[queue_id];
if (!vq)
return -1;
Expand All @@ -1475,6 +1478,9 @@ int rte_vhost_set_vring_base(int vid, uint16_t queue_id,
if (!dev)
return -1;

if (queue_id >= VHOST_MAX_VRING)
return -1;

vq = dev->virtqueue[queue_id];
if (!vq)
return -1;
Expand Down

0 comments on commit 215263f

Please sign in to comment.