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] [day] [month] [year] [list]
Message-ID: <20250213083217.77e18e10@kernel.org>
Date: Thu, 13 Feb 2025 08:32:17 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: "David S. Miller" <davem@...emloft.net>, Eric Dumazet
 <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Simon Horman
 <horms@...nel.org>, Kuniyuki Iwashima <kuni1840@...il.com>,
 <netdev@...r.kernel.org>, Yael Chemla <ychemla@...dia.com>
Subject: Re: [PATCH v4 net 2/3] net: Fix dev_net(dev) race in
 unregister_netdevice_notifier_dev_net().

On Wed, 12 Feb 2025 15:42:05 +0900 Kuniyuki Iwashima wrote:
> +static void rtnl_net_dev_lock(struct net_device *dev)
> +{
> +	struct net *net;
> +
> +#ifdef CONFIG_NET_NS
> +again:
> +#endif
> +	/* netns might be being dismantled. */
> +	rcu_read_lock();
> +	net = dev_net_rcu(dev);
> +	net_passive_inc(net);
> +	rcu_read_unlock();
> +
> +	rtnl_net_lock(net);
> +
> +#ifdef CONFIG_NET_NS
> +	/* dev might have been moved to another netns. */
> +	if (!net_eq(net, rcu_access_pointer(dev->nd_net.net))) {
> +		rtnl_net_unlock(net);
> +		net_passive_dec(net);
> +		goto again;
> +	}
> +#endif

Is there a plan to clean this up in net-next? Or perhaps after Eric's
dev_net() work? Otherwise I'm tempted to suggest to use a loop, maybe:

	bool again;

	do {
		again = false;

		/* netns might be being dismantled. */
		rcu_read_lock();
		net = dev_net_rcu(dev);
		net_passive_inc(net);
		rcu_read_unlock();

		rtnl_net_lock(net);

#ifdef CONFIG_NET_NS
		/* dev might have been moved to another netns. */
		if (!net_eq(net, rcu_access_pointer(dev->nd_net.net))) {
			rtnl_net_unlock(net);
			net_passive_dec(net);
			again = true;
		}
#endif
	} while (again);

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ