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: <Z4oM0cWuipPCWqeo@gauss3.secunet.de>
Date: Fri, 17 Jan 2025 08:54:57 +0100
From: Steffen Klassert <steffen.klassert@...unet.com>
To: Hangbin Liu <liuhangbin@...il.com>
CC: Jianbo Liu <jianbol@...dia.com>, Jakub Kicinski <kuba@...nel.org>,
	<netdev@...r.kernel.org>, Jay Vosburgh <jv@...sburgh.net>, Andy Gospodarek
	<andy@...yhouse.net>, "David S. Miller" <davem@...emloft.net>, Eric Dumazet
	<edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Nikolay Aleksandrov
	<razor@...ckwall.org>, Simon Horman <horms@...nel.org>, Tariq Toukan
	<tariqt@...dia.com>, Andrew Lunn <andrew+netdev@...n.ch>, Shuah Khan
	<shuah@...nel.org>, Herbert Xu <herbert@...dor.apana.org.au>, Sabrina Dubroca
	<sd@...asysnail.net>, <linux-kselftest@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH net 0/2] bond: fix xfrm offload feature during init

On Wed, Jan 15, 2025 at 09:19:33AM +0000, Hangbin Liu wrote:
> On Wed, Jan 08, 2025 at 07:15:00AM +0000, Hangbin Liu wrote:
> > > > > > > I don't know how to disable bonding sleeping since we use mutex_lock now.
> > > > > > > Hi Jianbo, do you have any idea?
> > > > > > > 
> > > > > > 
> > > > > > I think we should allow drivers to sleep in the callbacks. So, maybe it's
> > > > > > better to move driver's xdo_dev_state_delete out of state's spin lock.
> > > > > 
> > > > > I just check the code, xfrm_dev_state_delete() and later
> > > > > dev->xfrmdev_ops->xdo_dev_state_delete(x) have too many xfrm_state x
> > > > > checks. Can we really move it out of spin lock from xfrm_state_delete()
> > > > 
> > > > I tried to move the mutex lock code to a work queue, but found we need to
> > > > check (ipsec->xs == xs) in bonding. So we still need xfrm_state x during bond
> > > 
> > > Maybe I miss something, but why need to hold spin lock. You can keep xfrm
> > > state by its refcnt.
> > 
> > Do you mean move the xfrm_dev_state_delete() out of spin lock directly like:
> > 
> > diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
> > index 67ca7ac955a3..6881ddeb4360 100644
> > --- a/net/xfrm/xfrm_state.c
> > +++ b/net/xfrm/xfrm_state.c
> > @@ -766,13 +766,6 @@ int __xfrm_state_delete(struct xfrm_state *x)
> >  		if (x->encap_sk)
> >  			sock_put(rcu_dereference_raw(x->encap_sk));
> >  
> > -		xfrm_dev_state_delete(x);
> > -
> > -		/* All xfrm_state objects are created by xfrm_state_alloc.
> > -		 * The xfrm_state_alloc call gives a reference, and that
> > -		 * is what we are dropping here.
> > -		 */
> > -		xfrm_state_put(x);
> >  		err = 0;
> >  	}
> >  
> > @@ -787,8 +780,20 @@ int xfrm_state_delete(struct xfrm_state *x)
> >  	spin_lock_bh(&x->lock);
> >  	err = __xfrm_state_delete(x);
> >  	spin_unlock_bh(&x->lock);
> > +	if (err)
> > +		return err;
> >  
> > -	return err;
> > +	if (x->km.state == XFRM_STATE_DEAD) {
> > +		xfrm_dev_state_delete(x);
> > +
> > +		/* All xfrm_state objects are created by xfrm_state_alloc.
> > +		 * The xfrm_state_alloc call gives a reference, and that
> > +		 * is what we are dropping here.
> > +		 */
> > +		xfrm_state_put(x);
> > +	}
> > +
> > +	return 0;
> >  }
> >  EXPORT_SYMBOL(xfrm_state_delete);
> >  
> 
> Hi Jianbo,
> 
> I talked with Sabrina and it looks we can't simply do this. Because both
> xfrm_add_sa_expire() and xfrm_timer_handler() calling __xfrm_state_delete() under
> spin lock. If we move the xfrm_dev_state_delete() out of __xfrm_state_delete(),
> all the places need to be handled correctly.
> 
> At the same time xfrm_timer_handler() calling xfrm_dev_state_update_stats before
> __xfrm_state_delete(). Should we also take care of it to make sure the state
> change and delete are called at the same time?
> 
> Hi Steffen, do you have any comments?

Can't you just fix this in bonding? xfrm_timer_handler() can't sleep
anyway, even if you remove the spinlock, it is a timer function.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ