lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <18fac281.ae29.18c1535e9b4.Coremail.dinghao.liu@zju.edu.cn>
Date:   Tue, 28 Nov 2023 17:15:03 +0800 (GMT+08:00)
From:   dinghao.liu@....edu.cn
To:     "Tariq Toukan" <ttoukan.linux@...il.com>
Cc:     "Saeed Mahameed" <saeedm@...dia.com>,
        "Leon Romanovsky" <leon@...nel.org>,
        "David S. Miller" <davem@...emloft.net>,
        "Eric Dumazet" <edumazet@...gle.com>,
        "Jakub Kicinski" <kuba@...nel.org>,
        "Paolo Abeni" <pabeni@...hat.com>,
        "Zhengchao Shao" <shaozhengchao@...wei.com>,
        "Rahul Rameshbabu" <rrameshbabu@...dia.com>,
        "Simon Horman" <horms@...nel.org>,
        "Tariq Toukan" <tariqt@...dia.com>, "Aya Levin" <ayal@...dia.com>,
        netdev@...r.kernel.org, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net/mlx5e: fix a potential double-free in
 fs_any_create_groups

> 
> On 28/11/2023 10:28, Dinghao Liu wrote:
> > When kcalloc() for ft->g succeeds but kvzalloc() for in fails,
> > fs_any_create_groups() will free ft->g. However, its caller
> > fs_any_create_table() will free ft->g again through calling
> > mlx5e_destroy_flow_table(), which will lead to a double-free.
> > Fix this by removing the kfree(ft->g) in fs_any_create_groups().
> > 
> > Fixes: 0f575c20bf06 ("net/mlx5e: Introduce Flow Steering ANY API")
> > Signed-off-by: Dinghao Liu <dinghao.liu@....edu.cn>
> > ---
> >   drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c | 1 -
> >   1 file changed, 1 deletion(-)
> > 
> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
> > index be83ad9db82a..b222d23bfb9a 100644
> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs_tt_redirect.c
> > @@ -434,7 +434,6 @@ static int fs_any_create_groups(struct mlx5e_flow_table *ft)
> >   	ft->g = kcalloc(MLX5E_FS_UDP_NUM_GROUPS, sizeof(*ft->g), GFP_KERNEL);
> >   	in = kvzalloc(inlen, GFP_KERNEL);
> >   	if  (!in || !ft->g) {
> > -		kfree(ft->g);
> >   		kvfree(in);
> >   		return -ENOMEM;
> >   	}
> 
> Function fs_any_create_groups should not return failure without cleaning 
> itself up. This is not the right fix.
> Freeing ft->g and setting it to NULL will do it, and will avoid the 
> double free.

Thanks for your advice! I will resend a new patch soon.

Regards,
Dinghao

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ