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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z-HbGR1V9-1Fwf0H@mini-arch>
Date: Mon, 24 Mar 2025 15:22:17 -0700
From: Stanislav Fomichev <stfomichev@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Stanislav Fomichev <sdf@...ichev.me>, netdev@...r.kernel.org,
	davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
	linux-kernel@...r.kernel.org, jhs@...atatu.com,
	xiyou.wangcong@...il.com, jiri@...nulli.us, horms@...nel.org
Subject: Re: [PATCH net-next v2] net: hold netdev reference during
 qdisc_create request_module

On 03/24, Jakub Kicinski wrote:
> On Thu, 20 Mar 2025 09:51:03 -0700 Stanislav Fomichev wrote:
> >  			rtnl_lock();
> >  			netdev_lock_ops(dev);
> > +			dev_put(dev);
> >  			ops = qdisc_lookup_ops(kind);
> 
> I'm not sure if this is a correct sequence. Do we guarantee that locks
> will be taken before device is freed? I mean we do:
> 
> 	dev = netdev_wait_allrefs_any()
> 	free_netdev(dev)
> 		mutex_destroy(dev->lock)
> 
> without explicitly taking rtnl_lock() or netdev_lock(), so the moment
> that dev_put() is called the device may get freed from another thread
> - while its locked here.
> 
> My mental model is that taking the instance lock on a dev for which we
> only have a ref requires a dance implemented in __netdev_put_lock().

Good point, didn't think about it. In this case, I think I need to
get back to exposing locked/unlocked signal back to the callers.
Even with __netdev_put_lock, there is a case where the netdev is
dead and can't be relocked. Will add some new 'bool *locked' argument
and reset it here; the caller will skip unlock when 'locked == false'.
LMK if you have better ideas, otherwise will post something tomorrow.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ