[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250221084232.xksA_IQ4@linutronix.de>
Date: Fri, 21 Feb 2025 09:42:32 +0100
From: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: syzbot <syzbot+ecccecbc636b455f9084@...kaller.appspotmail.com>,
gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
syzkaller-bugs@...glegroups.com, tj@...nel.org,
Thomas Gleixner <tglx@...utronix.de>
Subject: [PATCH] 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: 6ef5b6fae3040 ("kernfs: Drop kernfs_rwsem while invoking lookup_positive_unlocked().")
Reported-by: Al Viro <viro@...iv.linux.org.uk>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@...utronix.de>
---
fs/kernfs/mount.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index f1cea282aae32..5124e196c2bfd 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -222,17 +222,17 @@ 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);
- }
+ }
+ if (WARN_ON(!knparent)) {
+ dput(dentry);
+ return ERR_PTR(-EINVAL);
}
do {
--
2.47.2
Powered by blists - more mailing lists