History

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.

Trond Myklebust committed 1 year ago

Commit e1ff7aa1 parent e1c24b51 file · +2 −1Browse files

Unified · Split

fs/namespace.c+2−1
@@ -2105,6 +2105,7 @@ static void warn_mandlock(void) · 2104 unmodified lines
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) · 3 unmodified lines
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 }