DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/mlx5: fix location of assert function
@ 2020-04-16 17:15 Asaf Penso
  2020-04-29 10:36 ` Raslan Darawsheh
  0 siblings, 1 reply; 2+ messages in thread
From: Asaf Penso @ 2020-04-16 17:15 UTC (permalink / raw)
  To: dev; +Cc: viacheslavo, dekelp, stable

The asserts makes sure that 'i' doesn't exceed the exepcted value.
This to prevent an out of bound access to dbr_bitmap.

The current location of the assert protects the assignment of
dbr_bitmap, but not the access to it.

Moved the assert to the correct place, to protect both cases.
Also, used an existing define for the assert.

Fixes: 21cae858 ("net/mlx5: allocate door-bells via DevX")
Cc: stable@dpdk.org

Signed-off-by: Asaf Penso <asafp@mellanox.com>
Reviewed-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
---
 drivers/net/mlx5/mlx5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index f8b134c..df12a3b 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1989,8 +1989,8 @@ struct mlx5_flow_id_pool *
 	     i++)
 		; /* Empty. */
 	/* Find the first clear bit. */
+	MLX5_ASSERT(i < MLX5_DBR_BITMAP_SIZE);
 	j = rte_bsf64(~page->dbr_bitmap[i]);
-	MLX5_ASSERT(i < (MLX5_DBR_PER_PAGE / 64));
 	page->dbr_bitmap[i] |= (1 << j);
 	page->dbr_count++;
 	*dbr_page = page;
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/mlx5: fix location of assert function
  2020-04-16 17:15 [dpdk-dev] [PATCH] net/mlx5: fix location of assert function Asaf Penso
@ 2020-04-29 10:36 ` Raslan Darawsheh
  0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2020-04-29 10:36 UTC (permalink / raw)
  To: Asaf Penso, dev; +Cc: Slava Ovsiienko, Dekel Peled, stable

Hi,
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Asaf Penso
> Sent: Thursday, April 16, 2020 8:15 PM
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; Dekel Peled
> <dekelp@mellanox.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix location of assert function
> 
> The asserts makes sure that 'i' doesn't exceed the exepcted value.
> This to prevent an out of bound access to dbr_bitmap.
> 
> The current location of the assert protects the assignment of
> dbr_bitmap, but not the access to it.
> 
> Moved the assert to the correct place, to protect both cases.
> Also, used an existing define for the assert.
> 
> Fixes: 21cae858 ("net/mlx5: allocate door-bells via DevX")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Asaf Penso <asafp@mellanox.com>
> Reviewed-by: Dekel Peled <dekelp@mellanox.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
> ---
>  drivers/net/mlx5/mlx5.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
> index f8b134c..df12a3b 100644
> --- a/drivers/net/mlx5/mlx5.c
> +++ b/drivers/net/mlx5/mlx5.c
> @@ -1989,8 +1989,8 @@ struct mlx5_flow_id_pool *
>  	     i++)
>  		; /* Empty. */
>  	/* Find the first clear bit. */
> +	MLX5_ASSERT(i < MLX5_DBR_BITMAP_SIZE);
>  	j = rte_bsf64(~page->dbr_bitmap[i]);
> -	MLX5_ASSERT(i < (MLX5_DBR_PER_PAGE / 64));
>  	page->dbr_bitmap[i] |= (1 << j);
>  	page->dbr_count++;
>  	*dbr_page = page;
> --
> 1.8.3.1


Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-29 10:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-16 17:15 [dpdk-dev] [PATCH] net/mlx5: fix location of assert function Asaf Penso
2020-04-29 10:36 ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).