Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

userns: Convert devpts to use kuid/kgid where appropriate

Acked-by: Serge Hallyn <serge.hallyn@canonical.com>
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>

+16 -9
+16 -8
fs/devpts/inode.c
··· 98 98 struct pts_mount_opts { 99 99 int setuid; 100 100 int setgid; 101 - uid_t uid; 102 - gid_t gid; 101 + kuid_t uid; 102 + kgid_t gid; 103 103 umode_t mode; 104 104 umode_t ptmxmode; 105 105 int newinstance; ··· 158 158 static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts) 159 159 { 160 160 char *p; 161 + kuid_t uid; 162 + kgid_t gid; 161 163 162 164 opts->setuid = 0; 163 165 opts->setgid = 0; 164 - opts->uid = 0; 165 - opts->gid = 0; 166 + opts->uid = GLOBAL_ROOT_UID; 167 + opts->gid = GLOBAL_ROOT_GID; 166 168 opts->mode = DEVPTS_DEFAULT_MODE; 167 169 opts->ptmxmode = DEVPTS_DEFAULT_PTMX_MODE; 168 170 opts->max = NR_UNIX98_PTY_MAX; ··· 186 184 case Opt_uid: 187 185 if (match_int(&args[0], &option)) 188 186 return -EINVAL; 189 - opts->uid = option; 187 + uid = make_kuid(current_user_ns(), option); 188 + if (!uid_valid(uid)) 189 + return -EINVAL; 190 + opts->uid = uid; 190 191 opts->setuid = 1; 191 192 break; 192 193 case Opt_gid: 193 194 if (match_int(&args[0], &option)) 194 195 return -EINVAL; 195 - opts->gid = option; 196 + gid = make_kgid(current_user_ns(), option); 197 + if (!gid_valid(gid)) 198 + return -EINVAL; 199 + opts->gid = gid; 196 200 opts->setgid = 1; 197 201 break; 198 202 case Opt_mode: ··· 323 315 struct pts_mount_opts *opts = &fsi->mount_opts; 324 316 325 317 if (opts->setuid) 326 - seq_printf(seq, ",uid=%u", opts->uid); 318 + seq_printf(seq, ",uid=%u", from_kuid_munged(&init_user_ns, opts->uid)); 327 319 if (opts->setgid) 328 - seq_printf(seq, ",gid=%u", opts->gid); 320 + seq_printf(seq, ",gid=%u", from_kgid_munged(&init_user_ns, opts->gid)); 329 321 seq_printf(seq, ",mode=%03o", opts->mode); 330 322 #ifdef CONFIG_DEVPTS_MULTIPLE_INSTANCES 331 323 seq_printf(seq, ",ptmxmode=%03o", opts->ptmxmode);
-1
init/Kconfig
··· 865 865 866 866 # List of kernel pieces that need user namespace work 867 867 # Features 868 - depends on UNIX98_PTYS = n 869 868 depends on CGROUPS = n 870 869 depends on MIGRATION = n 871 870 depends on NUMA = n