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: <20250521073401.67fbd1bc@kernel.org>
Date: Wed, 21 May 2025 07:34:01 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Stanislav Fomichev <stfomichev@...il.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, edumazet@...gle.com,
 pabeni@...hat.com, skalluru@...vell.com, manishc@...vell.com,
 andrew+netdev@...n.ch, michael.chan@...adcom.com,
 pavan.chebbi@...adcom.com, ajit.khaparde@...adcom.com,
 sriharsha.basavapatna@...adcom.com, somnath.kotur@...adcom.com,
 anthony.l.nguyen@...el.com, przemyslaw.kitszel@...el.com,
 tariqt@...dia.com, saeedm@...dia.com, louis.peens@...igine.com,
 shshaikh@...vell.com, GR-Linux-NIC-Dev@...vell.com, ecree.xilinx@...il.com,
 horms@...nel.org, dsahern@...nel.org, ruanjinjie@...wei.com,
 mheib@...hat.com, linux-kernel@...r.kernel.org,
 intel-wired-lan@...ts.osuosl.org, linux-rdma@...r.kernel.org,
 oss-drivers@...igine.com, linux-net-drivers@....com, leon@...nel.org
Subject: Re: [PATCH net-next 2/3] udp_tunnel: remove rtnl_lock dependency

On Tue, 20 May 2025 13:36:13 -0700 Stanislav Fomichev wrote:
> Drivers that are using ops lock and don't depend on RTNL lock
> still need to manage it because udp_tunnel's RTNL dependency.
> Introduce new udp_tunnel_nic_lock and use it instead of
> rtnl_lock. Drop non-UDP_TUNNEL_NIC_INFO_MAY_SLEEP mode from
> udp_tunnel infra (udp_tunnel_nic_device_sync_work needs to
> grab udp_tunnel_nic_lock mutex and might sleep).

There is a netdevsim-based test for this that needs to be fixed up.

> diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h
> index 2df3b8344eb5..7f5537fdf2c9 100644
> --- a/include/net/udp_tunnel.h
> +++ b/include/net/udp_tunnel.h
> @@ -221,19 +221,17 @@ static inline void udp_tunnel_encap_enable(struct sock *sk)
>  #define UDP_TUNNEL_NIC_MAX_TABLES	4
>  
>  enum udp_tunnel_nic_info_flags {
> -	/* Device callbacks may sleep */
> -	UDP_TUNNEL_NIC_INFO_MAY_SLEEP	= BIT(0),

Could we use a different lock for sleeping and non-sleeping drivers?

> @@ -554,11 +543,11 @@ static void __udp_tunnel_nic_reset_ntf(struct net_device *dev)
>  	struct udp_tunnel_nic *utn;
>  	unsigned int i, j;
>  
> -	ASSERT_RTNL();
> +	mutex_lock(&udp_tunnel_nic_lock);
>  
>  	utn = dev->udp_tunnel_nic;

utn and info's lifetimes are tied to the lifetime of the device
I think their existence can remain protected by the external locks

>  	if (!utn)
> -		return;
> +		goto unlock;
>  
>  	utn->need_sync = false;
>  	for (i = 0; i < utn->n_tables; i++)

> -	rtnl_lock();
> +	mutex_lock(&udp_tunnel_nic_lock);
>  	utn->work_pending = 0;
>  	__udp_tunnel_nic_device_sync(utn->dev, utn);
>  
> -	if (utn->need_replay)
> +	if (utn->need_replay) {
> +		rtnl_lock();
>  		udp_tunnel_nic_replay(utn->dev, utn);
> -	rtnl_unlock();
> +		rtnl_unlock();
> +	}
> +	mutex_unlock(&udp_tunnel_nic_lock);
>  }

What's the lock ordering between the new lock and rtnl lock?

BTW the lock could live in utn, right? We can't use the instance
lock because of sharing, but we could put the lock in utn?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ