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: <Zd_HAGqXSE6Nwcag@calendula>
Date: Thu, 29 Feb 2024 00:51:28 +0100
From: Pablo Neira Ayuso <pablo@...filter.org>
To: Alexander Ofitserov <oficerovas@...linux.org>
Cc: linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	edumazet@...gle.com, laforge@...monks.org, davem@...emloft.net,
	kuba@...nel.org, pabeni@...hat.com, kovalev@...linux.org,
	nickel@...linux.org, dutyrok@...linux.org, stable@...r.kernel.org
Subject: Re: [PATCH net] gtp: fix use-after-free and null-ptr-deref in
 gtp_newlink()

On Wed, Feb 28, 2024 at 02:47:03PM +0300, Alexander Ofitserov wrote:
> The gtp_link_ops operations structure for the subsystem must be
> registered after registering the gtp_net_ops pernet operations structure.

A fix for this was already applied, see:

commit 136cfaca22567a03bbb3bf53a43d8cb5748b80ec
Author: Vasiliy Kovalev <kovalev@...linux.org>
Date:   Wed Feb 14 19:27:33 2024 +0300

    gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp()

> diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
> index 2129ae42c7030..0ddec4cc84093 100644
> --- a/drivers/net/gtp.c
> +++ b/drivers/net/gtp.c
> @@ -1903,26 +1903,26 @@ static int __init gtp_init(void)
>  
>  	get_random_bytes(&gtp_h_initval, sizeof(gtp_h_initval));
>  
> -	err = rtnl_link_register(&gtp_link_ops);
> +	err = register_pernet_subsys(&gtp_net_ops);
>  	if (err < 0)
>  		goto error_out;

BTW, I like that this calls register_pernet_subsys() before
rtnl_link_register(), where a rtnetlink request could come before
pernet is set up.

> -	err = register_pernet_subsys(&gtp_net_ops);
> +	err = rtnl_link_register(&gtp_link_ops);
>  	if (err < 0)
> -		goto unreg_rtnl_link;
> +		goto unreg_pernet_subsys;
>  
>  	err = genl_register_family(&gtp_genl_family);
>  	if (err < 0)
> -		goto unreg_pernet_subsys;
> +		goto unreg_rtnl_link;
>  
>  	pr_info("GTP module loaded (pdp ctx size %zd bytes)\n",
>  		sizeof(struct pdp_ctx));
>  	return 0;
>  
> -unreg_pernet_subsys:
> -	unregister_pernet_subsys(&gtp_net_ops);
>  unreg_rtnl_link:
>  	rtnl_link_unregister(&gtp_link_ops);
> +unreg_pernet_subsys:
> +	unregister_pernet_subsys(&gtp_net_ops);
>  error_out:
>  	pr_err("error loading GTP module loaded\n");
>  	return err;
> -- 
> 2.42.1
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ