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-next>] [day] [month] [year] [list]
Message-ID: <20250206-scarlet-ermine-of-improvement-1fcac5@leitao>
Date: Thu, 6 Feb 2025 07:51:55 -0800
From: Breno Leitao <leitao@...ian.org>
To: kuniyu@...zon.com, kuba@...nel.org, edumazet@...gle.com,
	andrew+netdev@...n.ch
Cc: netdev@...r.kernel.org, ushankar@...estorage.com, kernel-team@...a.com
Subject: for_each_netdev_rcu() protected by RTNL and CONFIG_PROVE_RCU_LIST

Hello,

We're seeing CONFIG_PROVE_RCU_LIST warnings when for_each_netdev_rcu()
is called with RTNL held. While RTNL provides sufficient locking, the
RCU list checker isn't aware of this relationship, leading to false
positives like:

	WARNING: suspicious RCU usage
	net/core/dev.c:1143 RCU-list traversed in non-reader section!!

The initial discussion popped up in:

	https://lore.kernel.org/all/20250205-flying-coucal-of-influence-0dcbc3@leitao/

I've attempted a solution by modifying for_each_netdev_rcu():

	diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
	index 2a59034a5fa2f..59b18b58fa927 100644
	--- a/include/linux/netdevice.h
	+++ b/include/linux/netdevice.h
	@@ -3210,13 +3210,14 @@ netdev_notifier_info_to_extack(const struct netdev_notifier_info *info)
	int call_netdevice_notifiers(unsigned long val, struct net_device *dev);
	int call_netdevice_notifiers_info(unsigned long val,
					struct netdev_notifier_info *info);
	+bool lockdep_rtnl_net_is_held(struct net *net);

	#define for_each_netdev(net, d)		\
			list_for_each_entry(d, &(net)->dev_base_head, dev_list)
	#define for_each_netdev_reverse(net, d)	\
			list_for_each_entry_reverse(d, &(net)->dev_base_head, dev_list)
	#define for_each_netdev_rcu(net, d)		\
	-		list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list)
	+		list_for_each_entry_rcu(d, &(net)->dev_base_head, dev_list, lockdep_rtnl_net_is_held(net))
	#define for_each_netdev_safe(net, d, n)	\
			list_for_each_entry_safe(d, n, &(net)->dev_base_head, dev_list)
	#define for_each_netdev_continue(net, d)		\

However, I have concerns about using lockdep_rtnl_net_is_held() since it
has a dependency on CONFIG_DEBUG_NET_SMALL_RTNL.

Are there better approaches to silence these warnings when RTNL is held?
Any suggestions would be appreciated.

Thanks
--breno

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ