]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mnt_already_visible(): use guards
authorAl Viro <viro@zeniv.linux.org.uk>
Thu, 21 Aug 2025 00:24:23 +0000 (20:24 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Tue, 2 Sep 2025 23:35:57 +0000 (19:35 -0400)
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>
fs/namespace.c

index 86a86be2b0ef180583c9a90efd8d1cced870393b..a5d37b97088f5fb01f5156eb65a3046bdaed8486 100644 (file)
@@ -6232,9 +6232,8 @@ static bool mnt_already_visible(struct mnt_namespace *ns,
 {
        int new_flags = *new_mnt_flags;
        struct mount *mnt, *n;
-       bool visible = false;
 
-       down_read(&namespace_sem);
+       guard(namespace_shared)();
        rbtree_postorder_for_each_entry_safe(mnt, n, &ns->mounts, mnt_node) {
                struct mount *child;
                int mnt_flags;
@@ -6281,13 +6280,10 @@ static bool mnt_already_visible(struct mnt_namespace *ns,
                /* Preserve the locked attributes */
                *new_mnt_flags |= mnt_flags & (MNT_LOCK_READONLY | \
                                               MNT_LOCK_ATIME);
-               visible = true;
-               goto found;
+               return true;
        next:   ;
        }
-found:
-       up_read(&namespace_sem);
-       return visible;
+       return false;
 }
 
 static bool mount_too_revealing(const struct super_block *sb, int *new_mnt_flags)