aboutsummaryrefslogtreecommitdiffstats
path: root/fs/proc
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 14:11:09 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-10-02 14:11:09 -0400
commit437589a74b6a590d175f86cf9f7b2efcee7765e7 (patch)
tree37bf8635b1356d80ef002b00e84f3faf3d555a63 /fs/proc
parent68d47a137c3bef754923bccf73fb639c9b0bbd5e (diff)
parent72235465864d84cedb2d9f26f8e1de824ee20339 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
Pull user namespace changes from Eric Biederman: "This is a mostly modest set of changes to enable basic user namespace support. This allows the code to code to compile with user namespaces enabled and removes the assumption there is only the initial user namespace. Everything is converted except for the most complex of the filesystems: autofs4, 9p, afs, ceph, cifs, coda, fuse, gfs2, ncpfs, nfs, ocfs2 and xfs as those patches need a bit more review. The strategy is to push kuid_t and kgid_t values are far down into subsystems and filesystems as reasonable. Leaving the make_kuid and from_kuid operations to happen at the edge of userspace, as the values come off the disk, and as the values come in from the network. Letting compile type incompatible compile errors (present when user namespaces are enabled) guide me to find the issues. The most tricky areas have been the places where we had an implicit union of uid and gid values and were storing them in an unsigned int. Those places were converted into explicit unions. I made certain to handle those places with simple trivial patches. Out of that work I discovered we have generic interfaces for storing quota by projid. I had never heard of the project identifiers before. Adding full user namespace support for project identifiers accounts for most of the code size growth in my git tree. Ultimately there will be work to relax privlige checks from "capable(FOO)" to "ns_capable(user_ns, FOO)" where it is safe allowing root in a user names to do those things that today we only forbid to non-root users because it will confuse suid root applications. While I was pushing kuid_t and kgid_t changes deep into the audit code I made a few other cleanups. I capitalized on the fact we process netlink messages in the context of the message sender. I removed usage of NETLINK_CRED, and started directly using current->tty. Some of these patches have also made it into maintainer trees, with no problems from identical code from different trees showing up in linux-next. After reading through all of this code I feel like I might be able to win a game of kernel trivial pursuit." Fix up some fairly trivial conflicts in netfilter uid/git logging code. * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (107 commits) userns: Convert the ufs filesystem to use kuid/kgid where appropriate userns: Convert the udf filesystem to use kuid/kgid where appropriate userns: Convert ubifs to use kuid/kgid userns: Convert squashfs to use kuid/kgid where appropriate userns: Convert reiserfs to use kuid and kgid where appropriate userns: Convert jfs to use kuid/kgid where appropriate userns: Convert jffs2 to use kuid and kgid where appropriate userns: Convert hpfs to use kuid and kgid where appropriate userns: Convert btrfs to use kuid/kgid where appropriate userns: Convert bfs to use kuid/kgid where appropriate userns: Convert affs to use kuid/kgid wherwe appropriate userns: On alpha modify linux_to_osf_stat to use convert from kuids and kgids userns: On ia64 deal with current_uid and current_gid being kuid and kgid userns: On ppc convert current_uid from a kuid before printing. userns: Convert s390 getting uid and gid system calls to use kuid and kgid userns: Convert s390 hypfs to use kuid and kgid where appropriate userns: Convert binder ipc to use kuids userns: Teach security_path_chown to take kuids and kgids userns: Add user namespace support to IMA userns: Convert EVM to deal with kuids and kgids in it's hmac computation ...
Diffstat (limited to 'fs/proc')
-rw-r--r--fs/proc/base.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 1b6c84cbdb73..acd1960c28a2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1089,7 +1089,8 @@ static ssize_t proc_loginuid_read(struct file * file, char __user * buf,
1089 if (!task) 1089 if (!task)
1090 return -ESRCH; 1090 return -ESRCH;
1091 length = scnprintf(tmpbuf, TMPBUFLEN, "%u", 1091 length = scnprintf(tmpbuf, TMPBUFLEN, "%u",
1092 audit_get_loginuid(task)); 1092 from_kuid(file->f_cred->user_ns,
1093 audit_get_loginuid(task)));
1093 put_task_struct(task); 1094 put_task_struct(task);
1094 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length); 1095 return simple_read_from_buffer(buf, count, ppos, tmpbuf, length);
1095} 1096}
@@ -1101,6 +1102,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
1101 char *page, *tmp; 1102 char *page, *tmp;
1102 ssize_t length; 1103 ssize_t length;
1103 uid_t loginuid; 1104 uid_t loginuid;
1105 kuid_t kloginuid;
1104 1106
1105 rcu_read_lock(); 1107 rcu_read_lock();
1106 if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) { 1108 if (current != pid_task(proc_pid(inode), PIDTYPE_PID)) {
@@ -1130,7 +1132,13 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
1130 goto out_free_page; 1132 goto out_free_page;
1131 1133
1132 } 1134 }
1133 length = audit_set_loginuid(loginuid); 1135 kloginuid = make_kuid(file->f_cred->user_ns, loginuid);
1136 if (!uid_valid(kloginuid)) {
1137 length = -EINVAL;
1138 goto out_free_page;
1139 }
1140
1141 length = audit_set_loginuid(kloginuid);
1134 if (likely(length == 0)) 1142 if (likely(length == 0))
1135 length = count; 1143 length = count;
1136 1144
@@ -2983,6 +2991,11 @@ static int proc_gid_map_open(struct inode *inode, struct file *file)
2983 return proc_id_map_open(inode, file, &proc_gid_seq_operations); 2991 return proc_id_map_open(inode, file, &proc_gid_seq_operations);
2984} 2992}
2985 2993
2994static int proc_projid_map_open(struct inode *inode, struct file *file)
2995{
2996 return proc_id_map_open(inode, file, &proc_projid_seq_operations);
2997}
2998
2986static const struct file_operations proc_uid_map_operations = { 2999static const struct file_operations proc_uid_map_operations = {
2987 .open = proc_uid_map_open, 3000 .open = proc_uid_map_open,
2988 .write = proc_uid_map_write, 3001 .write = proc_uid_map_write,
@@ -2998,6 +3011,14 @@ static const struct file_operations proc_gid_map_operations = {
2998 .llseek = seq_lseek, 3011 .llseek = seq_lseek,
2999 .release = proc_id_map_release, 3012 .release = proc_id_map_release,
3000}; 3013};
3014
3015static const struct file_operations proc_projid_map_operations = {
3016 .open = proc_projid_map_open,
3017 .write = proc_projid_map_write,
3018 .read = seq_read,
3019 .llseek = seq_lseek,
3020 .release = proc_id_map_release,
3021};
3001#endif /* CONFIG_USER_NS */ 3022#endif /* CONFIG_USER_NS */
3002 3023
3003static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns, 3024static int proc_pid_personality(struct seq_file *m, struct pid_namespace *ns,
@@ -3105,6 +3126,7 @@ static const struct pid_entry tgid_base_stuff[] = {
3105#ifdef CONFIG_USER_NS 3126#ifdef CONFIG_USER_NS
3106 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations), 3127 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
3107 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations), 3128 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
3129 REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
3108#endif 3130#endif
3109}; 3131};
3110 3132
@@ -3468,6 +3490,7 @@ static const struct pid_entry tid_base_stuff[] = {
3468#ifdef CONFIG_USER_NS 3490#ifdef CONFIG_USER_NS
3469 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations), 3491 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
3470 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations), 3492 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
3493 REG("projid_map", S_IRUGO|S_IWUSR, proc_projid_map_operations),
3471#endif 3494#endif
3472}; 3495};
3473 3496