Skip to content

Commit 89156d9

Browse files
Trond Myklebustjfvogel
authored andcommitted
umount: Allow superblock owners to force umount
[ Upstream commit e1ff7aa34dec7e650159fd7ca8ec6af7cc428d9f ] 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 <[email protected]> Link: https://lore.kernel.org/r/12f212d4ef983714d065a6bb372fbb378753bf4c.1742315194.git.trond.myklebust@hammerspace.com Acked-by: "Eric W. Biederman" <[email protected]> Signed-off-by: Christian Brauner <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 67e85cfa951cb074dabd9ec5ef11b74e78cb5a06) Signed-off-by: Jack Vogel <[email protected]>
1 parent 1c0a8ac commit 89156d9

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)