Skip to content

Commit 2ca4dcc

Browse files
author
Christian Brauner
committed
fs/mount_setattr: tighten permission checks
We currently don't have any filesystems that support idmapped mounts which are mountable inside a user namespace. That was a deliberate decision for now as a userns root can just mount the filesystem themselves. So enforce this restriction explicitly until there's a real use-case for this. This way we can notice it and will have a chance to adapt and audit our translation helpers and fstests appropriately if we need to support such filesystems. Cc: Christoph Hellwig <hch@lst.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: stable@vger.kernel.org CC: linux-fsdevel@vger.kernel.org Suggested-by: Seth Forshee <seth.forshee@canonical.com> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
1 parent 6efb943 commit 2ca4dcc

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

fs/namespace.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3855,8 +3855,12 @@ static int can_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
38553855
if (!(m->mnt_sb->s_type->fs_flags & FS_ALLOW_IDMAP))
38563856
return -EINVAL;
38573857

3858+
/* Don't yet support filesystem mountable in user namespaces. */
3859+
if (m->mnt_sb->s_user_ns != &init_user_ns)
3860+
return -EINVAL;
3861+
38583862
/* We're not controlling the superblock. */
3859-
if (!ns_capable(m->mnt_sb->s_user_ns, CAP_SYS_ADMIN))
3863+
if (!capable(CAP_SYS_ADMIN))
38603864
return -EPERM;
38613865

38623866
/* Mount has already been visible in the filesystem hierarchy. */

0 commit comments

Comments
 (0)