All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] net/mlx5e: Fix two double free cases
@ 2020-12-28  8:48 Dinghao Liu
  2020-12-28 11:15 ` Leon Romanovsky
  2021-01-05 21:02 ` Saeed Mahameed
  0 siblings, 2 replies; 4+ messages in thread
From: Dinghao Liu @ 2020-12-28  8:48 UTC (permalink / raw)
  To: dinghao.liu, kjlu
  Cc: Saeed Mahameed, Leon Romanovsky, David S. Miller, Jakub Kicinski,
	Or Gerlitz, Gal Pressman, Maor Gottlieb, netdev, linux-rdma,
	linux-kernel

mlx5e_create_ttc_table_groups() frees ft->g on failure of
kvzalloc(), but such failure will be caught by its caller
in mlx5e_create_ttc_table() and ft->g will be freed again
in mlx5e_destroy_flow_table(). The same issue also occurs
in mlx5e_create_ttc_table_groups(). Set ft->g to NULL after
kfree() to avoid double free.

Fixes: 7b3722fa9ef64 ("net/mlx5e: Support RSS for GRE tunneled packets")
Fixes: 33cfaaa8f36ff ("net/mlx5e: Split the main flow steering table")
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---

Changelog:

v2: - Set ft->g to NULL after kfree() instead of removing kfree().
      Refine commit message.
---
 drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
index fa8149f6eb08..44a2dfbc3853 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
@@ -942,6 +942,7 @@ static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc,
 	in = kvzalloc(inlen, GFP_KERNEL);
 	if (!in) {
 		kfree(ft->g);
+		ft->g = NULL;
 		return -ENOMEM;
 	}
 
@@ -1087,6 +1088,7 @@ static int mlx5e_create_inner_ttc_table_groups(struct mlx5e_ttc_table *ttc)
 	in = kvzalloc(inlen, GFP_KERNEL);
 	if (!in) {
 		kfree(ft->g);
+		ft->g = NULL;
 		return -ENOMEM;
 	}
 
-- 
2.17.1


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

* Re: [PATCH] [v2] net/mlx5e: Fix two double free cases
  2020-12-28  8:48 [PATCH] [v2] net/mlx5e: Fix two double free cases Dinghao Liu
@ 2020-12-28 11:15 ` Leon Romanovsky
  2021-01-05 21:02 ` Saeed Mahameed
  1 sibling, 0 replies; 4+ messages in thread
From: Leon Romanovsky @ 2020-12-28 11:15 UTC (permalink / raw)
  To: Dinghao Liu
  Cc: kjlu, Saeed Mahameed, David S. Miller, Jakub Kicinski,
	Or Gerlitz, Gal Pressman, Maor Gottlieb, netdev, linux-rdma,
	linux-kernel

On Mon, Dec 28, 2020 at 04:48:40PM +0800, Dinghao Liu wrote:
> mlx5e_create_ttc_table_groups() frees ft->g on failure of
> kvzalloc(), but such failure will be caught by its caller
> in mlx5e_create_ttc_table() and ft->g will be freed again
> in mlx5e_destroy_flow_table(). The same issue also occurs
> in mlx5e_create_ttc_table_groups(). Set ft->g to NULL after
> kfree() to avoid double free.
>
> Fixes: 7b3722fa9ef64 ("net/mlx5e: Support RSS for GRE tunneled packets")
> Fixes: 33cfaaa8f36ff ("net/mlx5e: Split the main flow steering table")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
>
> Changelog:
>
> v2: - Set ft->g to NULL after kfree() instead of removing kfree().
>       Refine commit message.
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_fs.c | 2 ++
>  1 file changed, 2 insertions(+)
>

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

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

* Re: [PATCH] [v2] net/mlx5e: Fix two double free cases
  2020-12-28  8:48 [PATCH] [v2] net/mlx5e: Fix two double free cases Dinghao Liu
  2020-12-28 11:15 ` Leon Romanovsky
@ 2021-01-05 21:02 ` Saeed Mahameed
  2021-01-05 22:58   ` Saeed Mahameed
  1 sibling, 1 reply; 4+ messages in thread
From: Saeed Mahameed @ 2021-01-05 21:02 UTC (permalink / raw)
  To: Dinghao Liu, kjlu
  Cc: Leon Romanovsky, David S. Miller, Jakub Kicinski, Or Gerlitz,
	Gal Pressman, Maor Gottlieb, netdev, linux-rdma, linux-kernel

On Mon, 2020-12-28 at 16:48 +0800, Dinghao Liu wrote:
> mlx5e_create_ttc_table_groups() frees ft->g on failure of
> kvzalloc(), but such failure will be caught by its caller
> in mlx5e_create_ttc_table() and ft->g will be freed again
> in mlx5e_destroy_flow_table(). The same issue also occurs
> in mlx5e_create_ttc_table_groups(). Set ft->g to NULL after
> kfree() to avoid double free.
> 
> Fixes: 7b3722fa9ef64 ("net/mlx5e: Support RSS for GRE tunneled
> packets")
> Fixes: 33cfaaa8f36ff ("net/mlx5e: Split the main flow steering
> table")
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---
> 
> Changelog:
> 
> v2: - Set ft->g to NULL after kfree() instead of removing kfree().
>       Refine commit message.
> 

applied to net-next-mlx5,
Thanks!


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

* Re: [PATCH] [v2] net/mlx5e: Fix two double free cases
  2021-01-05 21:02 ` Saeed Mahameed
@ 2021-01-05 22:58   ` Saeed Mahameed
  0 siblings, 0 replies; 4+ messages in thread
From: Saeed Mahameed @ 2021-01-05 22:58 UTC (permalink / raw)
  To: Dinghao Liu, kjlu
  Cc: Leon Romanovsky, David S. Miller, Jakub Kicinski, Or Gerlitz,
	Gal Pressman, Maor Gottlieb, netdev, linux-rdma, linux-kernel

On Tue, 2021-01-05 at 13:02 -0800, Saeed Mahameed wrote:
> On Mon, 2020-12-28 at 16:48 +0800, Dinghao Liu wrote:
> > mlx5e_create_ttc_table_groups() frees ft->g on failure of
> > kvzalloc(), but such failure will be caught by its caller
> > in mlx5e_create_ttc_table() and ft->g will be freed again
> > in mlx5e_destroy_flow_table(). The same issue also occurs
> > in mlx5e_create_ttc_table_groups(). Set ft->g to NULL after
> > kfree() to avoid double free.
> > 
> > Fixes: 7b3722fa9ef64 ("net/mlx5e: Support RSS for GRE tunneled
                       ^ this is one digit too much..
Fixes line must start with a 12 char SHA and not 13 :).

I fixed this up, no need to do anything but just FYI.

> > packets")
> > Fixes: 33cfaaa8f36ff ("net/mlx5e: Split the main flow steering
> > table")
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> > 
> > Changelog:
> > 
> > v2: - Set ft->g to NULL after kfree() instead of removing kfree().
> >       Refine commit message.
> > 
> 
> applied to net-next-mlx5,
> Thanks!
> 


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

end of thread, other threads:[~2021-01-05 23:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-28  8:48 [PATCH] [v2] net/mlx5e: Fix two double free cases Dinghao Liu
2020-12-28 11:15 ` Leon Romanovsky
2021-01-05 21:02 ` Saeed Mahameed
2021-01-05 22:58   ` Saeed Mahameed

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.