Skip to content

Commit 49de700

Browse files
Al Virosmb49
authored andcommitted
clone_private_mnt(): make sure that caller has CAP_SYS_ADMIN in the right userns
BugLink: https://bugs.launchpad.net/bugs/2119603 [ Upstream commit c28f922 ] What we want is to verify there is that clone won't expose something hidden by a mount we wouldn't be able to undo. "Wouldn't be able to undo" may be a result of MNT_LOCKED on a child, but it may also come from lacking admin rights in the userns of the namespace mount belongs to. clone_private_mnt() checks the former, but not the latter. There's a number of rather confusing CAP_SYS_ADMIN checks in various userns during the mount, especially with the new mount API; they serve different purposes and in case of clone_private_mnt() they usually, but not always end up covering the missing check mentioned above. Reviewed-by: Christian Brauner <brauner@kernel.org> Reported-by: "Orlando, Noah" <Noah.Orlando@deshaw.com> Fixes: 427215d ("ovl: prevent private clone if bind mount is not allowed") Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Manuel Diewald <manuel.diewald@canonical.com> Signed-off-by: Mehmet Basaran <mehmet.basaran@canonical.com>
1 parent 70e3305 commit 49de700

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/namespace.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2307,6 +2307,11 @@ struct vfsmount *clone_private_mount(const struct path *path)
23072307
if (!check_mnt(old_mnt))
23082308
goto invalid;
23092309

2310+
if (!ns_capable(old_mnt->mnt_ns->user_ns, CAP_SYS_ADMIN)) {
2311+
up_read(&namespace_sem);
2312+
return ERR_PTR(-EPERM);
2313+
}
2314+
23102315
if (__has_locked_children(old_mnt, path->dentry))
23112316
goto invalid;
23122317

0 commit comments

Comments
 (0)