Skip to content

Commit 67e85cf

Browse files
Trond Myklebustgregkh
authored andcommitted
umount: Allow superblock owners to force umount
[ Upstream commit e1ff7aa ] Loosen the permission check on forced umount to allow users holding CAP_SYS_ADMIN privileges in namespaces that are privileged with respect to the userns that originally mounted the filesystem. Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Link: https://lore.kernel.org/r/12f212d4ef983714d065a6bb372fbb378753bf4c.1742315194.git.trond.myklebust@hammerspace.com Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5253568 commit 67e85cf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

fs/namespace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,6 +1986,7 @@ static void warn_mandlock(void)
19861986
static int can_umount(const struct path *path, int flags)
19871987
{
19881988
struct mount *mnt = real_mount(path->mnt);
1989+
struct super_block *sb = path->dentry->d_sb;
19891990

19901991
if (!may_mount())
19911992
return -EPERM;
@@ -1995,7 +1996,7 @@ static int can_umount(const struct path *path, int flags)
19951996
return -EINVAL;
19961997
if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */
19971998
return -EINVAL;
1998-
if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
1999+
if (flags & MNT_FORCE && !ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
19992000
return -EPERM;
20002001
return 0;
20012002
}

0 commit comments

Comments
 (0)