Commit c5020c5b authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Greg Kroah-Hartman
Browse files

kernfs: Move dput() outside of the RCU section.



Al Viro pointed out that dput() might sleep and must not be invoked
within an RCU section.

Keep only find_next_ancestor() winthin the RCU section.
Correct the wording in the comment.

Fixes: 6ef5b6fa ("kernfs: Drop kernfs_rwsem while invoking lookup_positive_unlocked().")
Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Link: https://lore.kernel.org/r/20250221084232.xksA_IQ4@linutronix.de


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent e965efc4
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -222,18 +222,18 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
	root = kernfs_root(kn);
	/*
	 * As long as kn is valid, its parent can not vanish. This is cgroup's
	 * kn so it not have its parent replaced. Therefore it is safe to use
	 * kn so it can't have its parent replaced. Therefore it is safe to use
	 * the ancestor node outside of the RCU or locked section.
	 */
	if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_INVARIANT_PARENT)))
		return ERR_PTR(-EINVAL);
	scoped_guard(rcu) {
		knparent = find_next_ancestor(kn, NULL);
	}
	if (WARN_ON(!knparent)) {
		dput(dentry);
		return ERR_PTR(-EINVAL);
	}
	}

	do {
		struct dentry *dtmp;