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: <20250516015114.40011-1-kuniyu@amazon.com>
Date: Thu, 15 May 2025 18:49:07 -0700
From: Kuniyuki Iwashima <kuniyu@...zon.com>
To: <kuba@...nel.org>
CC: <andrew+netdev@...n.ch>, <davem@...emloft.net>, <edumazet@...gle.com>,
	<horms@...nel.org>, <kuniyu@...zon.com>, <netdev@...r.kernel.org>,
	<pabeni@...hat.com>, <sdf@...ichev.me>
Subject: Re: [PATCH net-next] net: let lockdep compare instance locks

From: Jakub Kicinski <kuba@...nel.org>
Date: Thu, 15 May 2025 18:24:59 -0700
> AFAIU always returning -1 from lockdep's compare function
> basically disables checking of dependencies between given
> locks. Try to be a little more precise about what guarantees
> that instance locks won't deadlock.
> 
> Right now we only nest them under protection of rtnl_lock.
> Mostly in unregister_netdevice_many() and dev_close_many().
> 
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
> ---
>  include/net/netdev_lock.h | 29 +++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/include/net/netdev_lock.h b/include/net/netdev_lock.h
> index 2a753813f849..75a2da23100d 100644
> --- a/include/net/netdev_lock.h
> +++ b/include/net/netdev_lock.h
> @@ -99,16 +99,29 @@ static inline void netdev_unlock_ops_compat(struct net_device *dev)
>  static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,
>  				     const struct lockdep_map *b)
>  {
> -	/* Only lower devices currently grab the instance lock, so no
> -	 * real ordering issues can occur. In the near future, only
> -	 * hardware devices will grab instance lock which also does not
> -	 * involve any ordering. Suppress lockdep ordering warnings
> -	 * until (if) we start grabbing instance lock on pure SW
> -	 * devices (bond/team/veth/etc).
> -	 */
> +#ifdef CONFIG_DEBUG_NET_SMALL_RTNL
> +	const struct net_device *dev_a, *dev_b;
> +
> +	dev_a = container_of(a, struct net_device, lock.dep_map);
> +	dev_b = container_of(b, struct net_device, lock.dep_map);
> +#endif
> +
>  	if (a == b)
>  		return 0;
> -	return -1;
> +
> +	/* Locking multiple devices usually happens under rtnl_lock */
> +	if (lockdep_rtnl_is_held())
> +		return -1;
> +
> +#ifdef CONFIG_DEBUG_NET_SMALL_RTNL
> +	/* It's okay to use per-netns rtnl_lock if devices share netns */
> +	if (net_eq(dev_net(dev_a), dev_net(dev_b)) &&
> +	    lockdep_rtnl_net_is_held(dev_net(dev_a)))

Do we need

  !from_cleanup_net()

before lockdep_rtnl_net_is_held() ?

__rtnl_net_lock() is not held in ops_exit_rtnl_list() and
default_device_exit_batch() when calling unregister_netdevice_many().


> +		return -1;
> +#endif
> +
> +	/* Otherwise taking two instance locks is not allowed */
> +	return 1;
>  }
>  
>  #define netdev_lockdep_set_classes(dev)				\
> -- 
> 2.49.0
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ