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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <30a2d52a-527b-4cc3-94b6-9ee092859ae0@lunn.ch>
Date: Wed, 24 Jul 2024 12:35:36 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Jamie Bainbridge <jamie.bainbridge@...il.com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
	Eric Dumazet <edumazet@...gle.com>,
	Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
	Florian Fainelli <f.fainelli@...il.com>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH net 3/4] net-sysfs: check device is present when showing
 testing

On Wed, Jul 24, 2024 at 11:46:52AM +1000, Jamie Bainbridge wrote:
> A sysfs reader can race with a device reset or removal.
> 
> This was fixed for speed_show with commit 4224cfd7fb65 ("net-sysfs: add
> check for netdevice being present to speed_show") so add the same check
> to testing_show.
> 
> Fixes: db30a57779b1 ("net: Add testing sysfs attribute")
> 
> Signed-off-by: Jamie Bainbridge <jamie.bainbridge@...il.com>
> ---
>  net/core/net-sysfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
> index 3a539a2bd4d11c5f5d7b6f15a23d61439f178c3b..17927832a4fbb56d3e1dfbed29c567d70ab944be 100644
> --- a/net/core/net-sysfs.c
> +++ b/net/core/net-sysfs.c
> @@ -291,7 +291,7 @@ static ssize_t testing_show(struct device *dev,
>  {
>  	struct net_device *netdev = to_net_dev(dev);
>  
> -	if (netif_running(netdev))
> +	if (netif_running(netdev) && netif_device_present(netdev))

Maybe a dumb observation, but how can it be running if it is not
present?

And if we are not holding any locks, it might be gone by the time you
call netif_testing()?

>  		return sysfs_emit(buf, fmt_dec, !!netif_testing(netdev));

	Andrew

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ