vfs: Allow userns root to call mknod on owned filesystems.
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 23 May 2018 20:24:18 +0000 (15:24 -0500)
committerEric W. Biederman <ebiederm@xmission.com>
Thu, 24 May 2018 16:56:43 +0000 (11:56 -0500)
These filesystems already always set SB_I_NODEV so mknod will not be
useful for gaining control of any devices no matter their permissions.
This will allow overlayfs and applications like to fakeroot to use
device nodes to represent things on disk.

Acked-by: Seth Forshee <seth.forshee@canonical.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
fs/namei.c

index 942c1f096f6bd1c0add2dea3a63445d08c48ff1a..20335896dcce20c5e68dc982e1a6e96c5fb6b1a4 100644 (file)
@@ -3679,7 +3679,8 @@ int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
        if (error)
                return error;
 
-       if ((S_ISCHR(mode) || S_ISBLK(mode)) && !capable(CAP_MKNOD))
+       if ((S_ISCHR(mode) || S_ISBLK(mode)) &&
+           !ns_capable(dentry->d_sb->s_user_ns, CAP_MKNOD))
                return -EPERM;
 
        if (!dir->i_op->mknod)