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: <acc5f924-514d-40f3-a14f-7e569b56451b@blackwall.org>
Date: Sun, 17 Dec 2023 16:19:41 +0200
From: Nikolay Aleksandrov <razor@...ckwall.org>
To: Pedro Tammela <pctammela@...atatu.com>, netdev@...r.kernel.org
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
 pabeni@...hat.com, horms@...nel.org, jiri@...nulli.us, jhs@...atatu.com,
 victor@...atatu.com, martin@...ongswan.org, idosch@...dia.com,
 lucien.xin@...il.com, edwin.peer@...adcom.com, amcohen@...dia.com
Subject: Re: [PATCH net-next 2/2] net: rtnl: use rcu_replace_pointer_rtnl in
 rtnl_unregister_*

On 15/12/2023 19:57, Pedro Tammela wrote:
> With the introduction of the rcu_replace_pointer_rtnl helper,
> cleanup the rtnl_unregister_* functions to use the helper instead
> of open coding it.
> 
> Signed-off-by: Pedro Tammela <pctammela@...atatu.com>
> ---
>  net/core/rtnetlink.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index 5e0ab4c08f72..94c4572512b8 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -342,8 +342,7 @@ int rtnl_unregister(int protocol, int msgtype)
>  		return -ENOENT;
>  	}
>  
> -	link = rtnl_dereference(tab[msgindex]);
> -	RCU_INIT_POINTER(tab[msgindex], NULL);
> +	link = rcu_replace_pointer_rtnl(tab[msgindex], NULL);
>  	rtnl_unlock();
>  
>  	kfree_rcu(link, rcu);
> @@ -368,18 +367,13 @@ void rtnl_unregister_all(int protocol)
>  	BUG_ON(protocol < 0 || protocol > RTNL_FAMILY_MAX);
>  
>  	rtnl_lock();
> -	tab = rtnl_dereference(rtnl_msg_handlers[protocol]);
> +	tab = rcu_replace_pointer_rtnl(rtnl_msg_handlers[protocol], NULL);
>  	if (!tab) {
>  		rtnl_unlock();
>  		return;
>  	}
> -	RCU_INIT_POINTER(rtnl_msg_handlers[protocol], NULL);
>  	for (msgindex = 0; msgindex < RTM_NR_MSGTYPES; msgindex++) {
> -		link = rtnl_dereference(tab[msgindex]);
> -		if (!link)
> -			continue;
> -
> -		RCU_INIT_POINTER(tab[msgindex], NULL);
> +		link = rcu_replace_pointer_rtnl(tab[msgindex], NULL);
>  		kfree_rcu(link, rcu);
>  	}
>  	rtnl_unlock();

Reviewed-by: Nikolay Aleksandrov <razor@...ckwall.org>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ