aboutsummaryrefslogtreecommitdiffstats
path: root/fs/namespace.c
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2025-08-20 20:14:22 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2025-09-02 19:35:56 -0400
commit4151c3cc58698584e8b0427c40eeda671c3e08c6 (patch)
treea5f04fe1582b71a91de118c7014d621b8d5d5cd0 /fs/namespace.c
parent902e9904672bedcb25c6740d5c1d09e17de807eb (diff)
downloadrandom-4151c3cc58698584e8b0427c40eeda671c3e08c6.tar.gz
__is_local_mountpoint(): use guards
clean fit; namespace_shared due to iterating through ns->mounts. Reviewed-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/namespace.c')
-rw-r--r--fs/namespace.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index 1ae1ab8815c9b6..f1460ddd1486ec 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -906,17 +906,14 @@ bool __is_local_mountpoint(const struct dentry *dentry)
{
struct mnt_namespace *ns = current->nsproxy->mnt_ns;
struct mount *mnt, *n;
- bool is_covered = false;
- down_read(&namespace_sem);
- rbtree_postorder_for_each_entry_safe(mnt, n, &ns->mounts, mnt_node) {
- is_covered = (mnt->mnt_mountpoint == dentry);
- if (is_covered)
- break;
- }
- up_read(&namespace_sem);
+ guard(namespace_shared)();
+
+ rbtree_postorder_for_each_entry_safe(mnt, n, &ns->mounts, mnt_node)
+ if (mnt->mnt_mountpoint == dentry)
+ return true;
- return is_covered;
+ return false;
}
struct pinned_mountpoint {