[dpdk-stable] [PATCH 2/7] vhost: validate index in available entries API
Xia, Chenbo
chenbo.xia at intel.com
Wed Oct 21 13:28:53 CEST 2020
Hi Maxime,
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin at redhat.com>
> Sent: Tuesday, October 20, 2020 1:34 AM
> To: dev at dpdk.org; Xia, Chenbo <chenbo.xia at intel.com>; amorenoz at redhat.com
> Cc: Maxime Coquelin <maxime.coquelin at redhat.com>; stable at dpdk.org
> Subject: [PATCH 2/7] 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 at dpdk.org
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
> ---
> 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.26.2
Looking at the API again, I don't know if it is good to return 0 when there are no
available entries or other errors.
For this patch:
Reviewed-by: Chenbo Xia <chenbo.xia at intel.com>
More information about the stable
mailing list