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: <20241113074210.rlH2mJiD@linutronix.de>
Date: Wed, 13 Nov 2024 08:42:10 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Tejun Heo <tj@...nel.org>
Cc: cgroups@...r.kernel.org, linux-kernel@...r.kernel.org,
	Michal Koutný <mkoutny@...e.com>,
	"Paul E. McKenney" <paulmck@...nel.org>,
	Boqun Feng <boqun.feng@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Hillf Danton <hdanton@...a.com>,
	Johannes Weiner <hannes@...xchg.org>,
	Marco Elver <elver@...gle.com>, Zefan Li <lizefan.x@...edance.com>,
	tglx@...utronix.de
Subject: Re: [PATCH v2 1/2] kernfs: Make it possible to use RCU for
 kernfs_node::name lookup.

On 2024-11-12 08:52:11 [-1000], Tejun Heo wrote:
> Hello,
Hi,

> On Tue, Nov 12, 2024 at 04:52:38PM +0100, Sebastian Andrzej Siewior wrote:
> ...
> > KERNFS_ROOT_SAME_PARENT is added to signal that the parent never
> 
> Maybe KERNFS_ROOT_INVARIANT_PARENT captures it better?

Sure.

> ...
> > @@ -195,13 +191,47 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to,
> >   */
> >  int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen)
> >  {
> > +	struct kernfs_root *root;
> >  
> > +	guard(read_lock_irqsave)(&kernfs_rename_lock);
> > +	if (kn) {
> > +		root = kernfs_root(kn);
> > +		if (WARN_ON_ONCE(root->flags & KERNFS_ROOT_SAME_PARENT))
> > +			kn = NULL;
> 
> Hmm... does kn need to be set to NULL here?

actually no, because read_lock() implies RCU protection.

> > +	}
> > +
> > +	if (!kn)
> > +		return strscpy(buf, "(null)", buflen);
> > +
> > +	return strscpy(buf, kn->parent ? kn->name : "/", buflen);
> ...
> > +int kernfs_name_rcu(struct kernfs_node *kn, char *buf, size_t buflen)
> > +{
> > +	struct kernfs_root *root;
> > +
> > +	if (kn) {
> > +		root = kernfs_root(kn);
> > +		if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_SAME_PARENT)))
> > +			kn = NULL;
> 
> Ah, I suppose it's to keep things symmetric. That's fine.
> 
> > +	}
> > +	if (!kn)
> > +		return strscpy(buf, "(null)", buflen);
> > +
> > +	guard(rcu)();
> 
> Also, why are guards in different locations? Even when !SAME_PARENT, kn's
> can't jump across roots, so guard there can also be in the same location as
> this one?

I tried to limit the scope but it can be symmetrical.

> ...
> > @@ -200,7 +205,10 @@ struct kernfs_node {
> >  	 * parent directly.
> >  	 */
> >  	struct kernfs_node	*parent;
> > -	const char		*name;
> > +	union {
> > +		const char		__rcu *name_rcu;
> > +		const char		*name;
> > +	};
> 
> Wouldn't it be simpler if ->name is always __rcu and !SAME_PARENT just
> requires further protection on the read side?

Let me try that again.

> Thanks.
> 

Sebastian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ