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] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 25 Feb 2022 14:14:12 +0200
From:   Roi Dayan <roid@...dia.com>
To:     Colin Ian King <colin.i.king@...il.com>,
        Saeed Mahameed <saeedm@...dia.com>,
        Leon Romanovsky <leon@...nel.org>,
        "David S . Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Nathan Chancellor <nathan@...nel.org>,
        Nick Desaulniers <ndesaulniers@...gle.com>,
        <netdev@...r.kernel.org>, <linux-rdma@...r.kernel.org>
CC:     <kernel-janitors@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <llvm@...ts.linux.dev>
Subject: Re: [PATCH] net/mlx5e: Fix return of a kfree'd object instead of NULL



On 2022-02-25 12:15 AM, Colin Ian King wrote:
> Currently in the case where parse_attr fails to be allocated the memory
> pointed to by attr2 is kfree'd but the non-null pointer attr2 is returned
> and a potential use of a kfree'd object can occur.  Fix this by returning
> NULL to indicate a memory allocation error.
> 
> Addresses issue found by clang-scan:
> drivers/net/ethernet/mellanox/mlx5/core/en_tc.c:3401:3: warning: Use of
> memory after it is freed [unix.Malloc]
> 
> Fixes: 8300f225268b ("net/mlx5e: Create new flow attr for multi table actions")
> Signed-off-by: Colin Ian King <colin.i.king@...il.com>
> ---
>   drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> index 76a015dfc5fc..c0776a4a3845 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
> @@ -3398,7 +3398,7 @@ mlx5e_clone_flow_attr_for_post_act(struct mlx5_flow_attr *attr,
>   	if (!attr2 || !parse_attr) {
>   		kvfree(parse_attr);
>   		kfree(attr2);
> -		return attr2;
> +		return NULL;
>   	}
>   
>   	memcpy(attr2, attr, attr_sz);


thanks!

Reviewed-by: Roi Dayan <roid@...dia.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ