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]
Message-ID: <ZZNyvTdnTz2Usd4j@TONYMAC-ALIBABA.local>
Date: Tue, 2 Jan 2024 10:19:41 +0800
From: Tony Lu <tonylu@...ux.alibaba.com>
To: Markus Elfring <Markus.Elfring@....de>
Cc: linux-s390@...r.kernel.org, netdev@...r.kernel.org,
	kernel-janitors@...r.kernel.org,
	"David S. Miller" <davem@...emloft.net>,
	"D. Wythe" <alibuda@...ux.alibaba.com>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Jan Karcher <jaka@...ux.ibm.com>,
	Paolo Abeni <pabeni@...hat.com>, Wen Gu <guwen@...ux.alibaba.com>,
	Wenjia Zhang <wenjia@...ux.ibm.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] net/smc: Improve exception handling in
 smc_llc_cli_add_link_invite()

On Sun, Dec 31, 2023 at 04:00:22PM +0100, Markus Elfring wrote:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Sun, 31 Dec 2023 15:42:07 +0100
> 
> The kfree() function was called in some cases by
> the smc_llc_cli_add_link_invite() function during error handling
> even if the passed variable contained a null pointer.
> This issue was detected by using the Coccinelle software.
> 
> * Thus use another label.
> 
> * Merge two if statements.
> 
> * Omit an initialisation (for the variable "ini")
>   which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>

Thank you, LGTM. Also net and Fixes tags are needed.

Reviewed-by: Tony Lu <tonylu@...ux.alibaba.com>
> ---
>  net/smc/smc_llc.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/net/smc/smc_llc.c b/net/smc/smc_llc.c
> index 018ce8133b02..2ff24a7feb26 100644
> --- a/net/smc/smc_llc.c
> +++ b/net/smc/smc_llc.c
> @@ -1163,23 +1163,21 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link,
>  					struct smc_llc_qentry *qentry)
>  {
>  	struct smc_link_group *lgr = smc_get_lgr(link);
> -	struct smc_init_info *ini = NULL;
> +	struct smc_init_info *ini;
> 
>  	if (lgr->smc_version == SMC_V2) {
>  		smc_llc_send_request_add_link(link);
> -		goto out;
> +		goto free_qentry;
>  	}
> 
>  	if (lgr->type == SMC_LGR_SYMMETRIC ||
> -	    lgr->type == SMC_LGR_ASYMMETRIC_PEER)
> -		goto out;
> -
> -	if (lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1)
> -		goto out;
> +	    lgr->type == SMC_LGR_ASYMMETRIC_PEER ||
> +	    lgr->type == SMC_LGR_SINGLE && lgr->max_links <= 1)
> +		goto free_qentry;
> 
>  	ini = kzalloc(sizeof(*ini), GFP_KERNEL);
>  	if (!ini)
> -		goto out;
> +		goto free_qentry;
> 
>  	ini->vlan_id = lgr->vlan_id;
>  	smc_pnet_find_alt_roce(lgr, ini, link->smcibdev);
> @@ -1190,6 +1188,7 @@ static void smc_llc_cli_add_link_invite(struct smc_link *link,
>  			      ini->ib_gid, NULL, SMC_LLC_REQ);
>  out:
>  	kfree(ini);
> +free_qentry:
>  	kfree(qentry);
>  }
> 
> --
> 2.43.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ