diff options
Diffstat (limited to 'fs/devpts/inode.c')
-rw-r--r-- | fs/devpts/inode.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index 472e6befc54d..073d30b9d1ac 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -243,6 +243,13 @@ static int mknod_ptmx(struct super_block *sb) | |||
243 | struct dentry *root = sb->s_root; | 243 | struct dentry *root = sb->s_root; |
244 | struct pts_fs_info *fsi = DEVPTS_SB(sb); | 244 | struct pts_fs_info *fsi = DEVPTS_SB(sb); |
245 | struct pts_mount_opts *opts = &fsi->mount_opts; | 245 | struct pts_mount_opts *opts = &fsi->mount_opts; |
246 | kuid_t root_uid; | ||
247 | kgid_t root_gid; | ||
248 | |||
249 | root_uid = make_kuid(current_user_ns(), 0); | ||
250 | root_gid = make_kgid(current_user_ns(), 0); | ||
251 | if (!uid_valid(root_uid) || !gid_valid(root_gid)) | ||
252 | return -EINVAL; | ||
246 | 253 | ||
247 | mutex_lock(&root->d_inode->i_mutex); | 254 | mutex_lock(&root->d_inode->i_mutex); |
248 | 255 | ||
@@ -273,6 +280,8 @@ static int mknod_ptmx(struct super_block *sb) | |||
273 | 280 | ||
274 | mode = S_IFCHR|opts->ptmxmode; | 281 | mode = S_IFCHR|opts->ptmxmode; |
275 | init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2)); | 282 | init_special_inode(inode, mode, MKDEV(TTYAUX_MAJOR, 2)); |
283 | inode->i_uid = root_uid; | ||
284 | inode->i_gid = root_gid; | ||
276 | 285 | ||
277 | d_add(dentry, inode); | 286 | d_add(dentry, inode); |
278 | 287 | ||
@@ -438,6 +447,12 @@ static struct dentry *devpts_mount(struct file_system_type *fs_type, | |||
438 | if (error) | 447 | if (error) |
439 | return ERR_PTR(error); | 448 | return ERR_PTR(error); |
440 | 449 | ||
450 | /* Require newinstance for all user namespace mounts to ensure | ||
451 | * the mount options are not changed. | ||
452 | */ | ||
453 | if ((current_user_ns() != &init_user_ns) && !opts.newinstance) | ||
454 | return ERR_PTR(-EINVAL); | ||
455 | |||
441 | if (opts.newinstance) | 456 | if (opts.newinstance) |
442 | s = sget(fs_type, NULL, set_anon_super, flags, NULL); | 457 | s = sget(fs_type, NULL, set_anon_super, flags, NULL); |
443 | else | 458 | else |
@@ -491,6 +506,9 @@ static struct file_system_type devpts_fs_type = { | |||
491 | .name = "devpts", | 506 | .name = "devpts", |
492 | .mount = devpts_mount, | 507 | .mount = devpts_mount, |
493 | .kill_sb = devpts_kill_sb, | 508 | .kill_sb = devpts_kill_sb, |
509 | #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES | ||
510 | .fs_flags = FS_USERNS_MOUNT | FS_USERNS_DEV_MOUNT, | ||
511 | #endif | ||
494 | }; | 512 | }; |
495 | 513 | ||
496 | /* | 514 | /* |