[3/3] vhost: fix possible out of bound access

Message ID 20181028010846.81730-3-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [1/3] lib: fix shifting 32 bits signed variable 31 times |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ferruh Yigit Oct. 28, 2018, 1:08 a.m. UTC
  Fixes: d7280c9fffcb ("vhost: support selective datapath")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 lib/librte_vhost/vdpa.c | 3 +++
 1 file changed, 3 insertions(+)
  

Comments

Maxime Coquelin Oct. 31, 2018, 5:28 p.m. UTC | #1
On 10/28/18 2:08 AM, Ferruh Yigit wrote:
> Fixes: d7280c9fffcb ("vhost: support selective datapath")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---
>   lib/librte_vhost/vdpa.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c
> index c2c5dff1d..e7d849ee0 100644
> --- a/lib/librte_vhost/vdpa.c
> +++ b/lib/librte_vhost/vdpa.c
> @@ -63,6 +63,9 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
>   			break;
>   	}
>   
> +	if (i == MAX_VHOST_DEVICE)
> +		return -1;
> +
>   	sprintf(device_name, "vdpa-dev-%d", i);
>   	dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device),
>   			RTE_CACHE_LINE_SIZE);
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  

Patch

diff --git a/lib/librte_vhost/vdpa.c b/lib/librte_vhost/vdpa.c
index c2c5dff1d..e7d849ee0 100644
--- a/lib/librte_vhost/vdpa.c
+++ b/lib/librte_vhost/vdpa.c
@@ -63,6 +63,9 @@  rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
 			break;
 	}
 
+	if (i == MAX_VHOST_DEVICE)
+		return -1;
+
 	sprintf(device_name, "vdpa-dev-%d", i);
 	dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device),
 			RTE_CACHE_LINE_SIZE);