net/mlx5: fix the alloc size of rqt attribute

Message ID 1569493335-44790-1-git-send-email-orika@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Raslan Darawsheh
Headers
Series net/mlx5: fix the alloc size of rqt attribute |

Checks

Context Check Description
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Ori Kam Sept. 26, 2019, 10:22 a.m. UTC
  The receive queues list size is based on the size of uint32_t, so
when allocating the memory, the correct value should be used. Or
else there is risk to corrupt the memory, depending on the queues
number, because there is some pad area for alignment. If the queue
number is not large enough, the issue couldn't be observed.

Based on Bing fix.

Fixes: dc9ceff73c99 ("net/mlx5: create advanced RxQ via DevX")
Cc: dekelp@mellanox.com

Signed-off-by: Ori Kam <orika@mellanox.com>
---
 drivers/net/mlx5/mlx5_rxq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Slava Ovsiienko Oct. 8, 2019, 9:41 a.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ori Kam
> Sent: Thursday, September 26, 2019 13:22
> To: Matan Azrad <matan@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix the alloc size of rqt attribute
> 
> The receive queues list size is based on the size of uint32_t, so when
> allocating the memory, the correct value should be used. Or else there is risk
> to corrupt the memory, depending on the queues number, because there is
> some pad area for alignment. If the queue number is not large enough, the
> issue couldn't be observed.
> 
> Based on Bing fix.
> 
> Fixes: dc9ceff73c99 ("net/mlx5: create advanced RxQ via DevX")
> Cc: dekelp@mellanox.com
> 
> Signed-off-by: Ori Kam <orika@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>

> ---
>  drivers/net/mlx5/mlx5_rxq.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c index
> a1fdeef..0db065a 100644
> --- a/drivers/net/mlx5/mlx5_rxq.c
> +++ b/drivers/net/mlx5/mlx5_rxq.c
> @@ -1936,7 +1936,7 @@ struct mlx5_rxq_ctrl *
>  		struct mlx5_devx_rqt_attr *rqt_attr = NULL;
> 
>  		rqt_attr = rte_calloc(__func__, 1, sizeof(*rqt_attr) +
> -				      queues_n * sizeof(uint16_t), 0);
> +				      queues_n * sizeof(uint32_t), 0);
>  		if (!rqt_attr) {
>  			DRV_LOG(ERR, "port %u cannot allocate RQT
> resources",
>  				dev->data->port_id);
> --
> 1.8.3.1
  
Raslan Darawsheh Oct. 8, 2019, 11:52 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ori Kam
> Sent: Thursday, September 26, 2019 1:22 PM
> To: Matan Azrad <matan@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix the alloc size of rqt attribute
> 
> The receive queues list size is based on the size of uint32_t, so
> when allocating the memory, the correct value should be used. Or
> else there is risk to corrupt the memory, depending on the queues
> number, because there is some pad area for alignment. If the queue
> number is not large enough, the issue couldn't be observed.
> 
> Based on Bing fix.
> 
> Fixes: dc9ceff73c99 ("net/mlx5: create advanced RxQ via DevX")
> Cc: dekelp@mellanox.com
> 
> Signed-off-by: Ori Kam <orika@mellanox.com>

Added Cc: stable@dpdk.org

Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh
  
Ferruh Yigit Oct. 8, 2019, 12:33 p.m. UTC | #3
On 9/26/2019 11:22 AM, Ori Kam wrote:
> The receive queues list size is based on the size of uint32_t, so
> when allocating the memory, the correct value should be used. Or
> else there is risk to corrupt the memory, depending on the queues
> number, because there is some pad area for alignment. If the queue
> number is not large enough, the issue couldn't be observed.
> 
> Based on Bing fix.
> 

Bing fix?
  
Raslan Darawsheh Oct. 10, 2019, 8:36 a.m. UTC | #4
Hi Ferruh,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ferruh Yigit
> Sent: Tuesday, October 8, 2019 3:33 PM
> To: Ori Kam <orika@mellanox.com>; Matan Azrad <matan@mellanox.com>
> Cc: dev@dpdk.org; Dekel Peled <dekelp@mellanox.com>
> Subject: Re: [dpdk-dev] [PATCH] net/mlx5: fix the alloc size of rqt attribute
> 
> On 9/26/2019 11:22 AM, Ori Kam wrote:
> > The receive queues list size is based on the size of uint32_t, so
> > when allocating the memory, the correct value should be used. Or
> > else there is risk to corrupt the memory, depending on the queues
> > number, because there is some pad area for alignment. If the queue
> > number is not large enough, the issue couldn't be observed.
> >
> > Based on Bing fix.
> >
> 
> Bing fix?

I've simply removed this from the commit log after having a talk to Ori since he is on vacation.
It's just something left which is not necessary

Kindest regards,
Raslan Darawsheh
  

Patch

diff --git a/drivers/net/mlx5/mlx5_rxq.c b/drivers/net/mlx5/mlx5_rxq.c
index a1fdeef..0db065a 100644
--- a/drivers/net/mlx5/mlx5_rxq.c
+++ b/drivers/net/mlx5/mlx5_rxq.c
@@ -1936,7 +1936,7 @@  struct mlx5_rxq_ctrl *
 		struct mlx5_devx_rqt_attr *rqt_attr = NULL;
 
 		rqt_attr = rte_calloc(__func__, 1, sizeof(*rqt_attr) +
-				      queues_n * sizeof(uint16_t), 0);
+				      queues_n * sizeof(uint32_t), 0);
 		if (!rqt_attr) {
 			DRV_LOG(ERR, "port %u cannot allocate RQT resources",
 				dev->data->port_id);