Skip to content

Commit e1ff7aa

Browse files
Trond Myklebustbrauner
authored andcommitted
umount: Allow superblock owners to force umount
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>
1 parent e1c24b5 commit e1ff7aa

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

fs/namespace.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,6 +2105,7 @@ static void warn_mandlock(void)
21052105
static int can_umount(const struct path *path, int flags)
21062106
{
21072107
struct mount *mnt = real_mount(path->mnt);
2108+
struct super_block *sb = path->dentry->d_sb;
21082109

21092110
if (!may_mount())
21102111
return -EPERM;
@@ -2114,7 +2115,7 @@ static int can_umount(const struct path *path, int flags)
21142115
return -EINVAL;
21152116
if (mnt->mnt.mnt_flags & MNT_LOCKED) /* Check optimistically */
21162117
return -EINVAL;
2117-
if (flags & MNT_FORCE && !capable(CAP_SYS_ADMIN))
2118+
if (flags & MNT_FORCE && !ns_capable(sb->s_user_ns, CAP_SYS_ADMIN))
21182119
return -EPERM;
21192120
return 0;
21202121
}

0 commit comments

Comments
 (0)