mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00
kernfs: Acquire kernfs_rwsem in kernfs_node_dentry().
kernfs_node_dentry() passes kernfs_node::name to lookup_positive_unlocked(). Acquire kernfs_root::kernfs_rwsem to ensure the node is not renamed during the operation. Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Link: https://lore.kernel.org/r/20250213145023.2820193-4-bigeasy@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
122ab92dee
commit
5b2fabf7fe
1 changed files with 4 additions and 0 deletions
|
@ -209,6 +209,7 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
|
||||||
{
|
{
|
||||||
struct dentry *dentry;
|
struct dentry *dentry;
|
||||||
struct kernfs_node *knparent;
|
struct kernfs_node *knparent;
|
||||||
|
struct kernfs_root *root;
|
||||||
|
|
||||||
BUG_ON(sb->s_op != &kernfs_sops);
|
BUG_ON(sb->s_op != &kernfs_sops);
|
||||||
|
|
||||||
|
@ -218,6 +219,9 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
|
||||||
if (!kn->parent)
|
if (!kn->parent)
|
||||||
return dentry;
|
return dentry;
|
||||||
|
|
||||||
|
root = kernfs_root(kn);
|
||||||
|
guard(rwsem_read)(&root->kernfs_rwsem);
|
||||||
|
|
||||||
knparent = find_next_ancestor(kn, NULL);
|
knparent = find_next_ancestor(kn, NULL);
|
||||||
if (WARN_ON(!knparent)) {
|
if (WARN_ON(!knparent)) {
|
||||||
dput(dentry);
|
dput(dentry);
|
||||||
|
|
Loading…
Add table
Reference in a new issue