[3/7] vhost: validate index in guest notification API
Checks
Commit Message
This patch validates the queue index parameter, in order
to ensure neither out-of-bound accesses nor NULL pointer
dereferencing happen.
Fixes: 9eed6bfd2efb ("vhost: allow to enable or disable features")
Cc: stable@dpdk.org
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
lib/librte_vhost/vhost.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Tuesday, October 20, 2020 1:34 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>; stable@dpdk.org
> Subject: [PATCH 3/7] vhost: validate index in guest notification API
>
> This patch validates the queue index parameter, in order
> to ensure neither out-of-bound accesses nor NULL pointer
> dereferencing happen.
>
> Fixes: 9eed6bfd2efb ("vhost: allow to enable or disable features")
> Cc: stable@dpdk.org
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin@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 193dafc369..801a1a5098 100644
> --- a/lib/librte_vhost/vhost.c
> +++ b/lib/librte_vhost/vhost.c
> @@ -1352,7 +1352,12 @@ rte_vhost_enable_guest_notification(int vid,
> uint16_t queue_id, int enable)
> if (!dev)
> return -1;
>
> + if (queue_id >= VHOST_MAX_VRING)
> + return -1;
> +
> vq = dev->virtqueue[queue_id];
> + if (!vq)
> + return -1;
>
> rte_spinlock_lock(&vq->access_lock);
>
> --
> 2.26.2
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
@@ -1352,7 +1352,12 @@ rte_vhost_enable_guest_notification(int vid, uint16_t queue_id, int enable)
if (!dev)
return -1;
+ if (queue_id >= VHOST_MAX_VRING)
+ return -1;
+
vq = dev->virtqueue[queue_id];
+ if (!vq)
+ return -1;
rte_spinlock_lock(&vq->access_lock);