summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fs/namespace.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/fs/namespace.c b/fs/namespace.c
index cf680fbf015e..0474b3a93dbf 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -6194,23 +6194,20 @@ bool our_mnt(struct vfsmount *mnt)
bool current_chrooted(void)
{
/* Does the current process have a non-standard root */
- struct mount *root = current->nsproxy->mnt_ns->root;
- struct path fs_root;
- bool chrooted;
+ struct path fs_root __free(path_put) = {};
+ struct mount *root;
get_fs_root(current->fs, &fs_root);
/* Find the namespace root */
- read_seqlock_excl(&mount_lock);
+ guard(mount_locked_reader)();
+
+ root = current->nsproxy->mnt_ns->root;
while (unlikely(root->overmount))
root = root->overmount;
- chrooted = fs_root.mnt != &root->mnt || !path_mounted(&fs_root);
-
- read_sequnlock_excl(&mount_lock);
- path_put(&fs_root);
- return chrooted;
+ return fs_root.mnt != &root->mnt || !path_mounted(&fs_root);
}
static bool mnt_already_visible(struct mnt_namespace *ns,