aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2011-11-17 02:20:58 -0500
committerEric W. Biederman <ebiederm@xmission.com>2012-04-07 20:11:46 -0400
commit7b44ab978b77a91b327058a0f4db7e6fcdb90b92 (patch)
tree632c872f0b88d001f1bddce2c0aacd77bf062454 /fs
parent5673a94c14574d7c6495c320c6b0e480673d54bd (diff)
userns: Disassociate user_struct from the user_namespace.
Modify alloc_uid to take a kuid and make the user hash table global. Stop holding a reference to the user namespace in struct user_struct. This simplifies the code and makes the per user accounting not care about which user namespace a uid happens to appear in. Acked-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/ioprio.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c
index 0f1b9515213b..8e35e964d9ed 100644
--- a/fs/ioprio.c
+++ b/fs/ioprio.c
@@ -65,6 +65,7 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
65 struct task_struct *p, *g; 65 struct task_struct *p, *g;
66 struct user_struct *user; 66 struct user_struct *user;
67 struct pid *pgrp; 67 struct pid *pgrp;
68 kuid_t uid;
68 int ret; 69 int ret;
69 70
70 switch (class) { 71 switch (class) {
@@ -110,16 +111,21 @@ SYSCALL_DEFINE3(ioprio_set, int, which, int, who, int, ioprio)
110 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); 111 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
111 break; 112 break;
112 case IOPRIO_WHO_USER: 113 case IOPRIO_WHO_USER:
114 uid = make_kuid(current_user_ns(), who);
115 if (!uid_valid(uid))
116 break;
113 if (!who) 117 if (!who)
114 user = current_user(); 118 user = current_user();
115 else 119 else
116 user = find_user(who); 120 user = find_user(uid);
117 121
118 if (!user) 122 if (!user)
119 break; 123 break;
120 124
121 do_each_thread(g, p) { 125 do_each_thread(g, p) {
122 if (__task_cred(p)->uid != who) 126 const struct cred *tcred = __task_cred(p);
127 kuid_t tcred_uid = make_kuid(tcred->user_ns, tcred->uid);
128 if (!uid_eq(tcred_uid, uid))
123 continue; 129 continue;
124 ret = set_task_ioprio(p, ioprio); 130 ret = set_task_ioprio(p, ioprio);
125 if (ret) 131 if (ret)
@@ -174,6 +180,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
174 struct task_struct *g, *p; 180 struct task_struct *g, *p;
175 struct user_struct *user; 181 struct user_struct *user;
176 struct pid *pgrp; 182 struct pid *pgrp;
183 kuid_t uid;
177 int ret = -ESRCH; 184 int ret = -ESRCH;
178 int tmpio; 185 int tmpio;
179 186
@@ -203,16 +210,19 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who)
203 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); 210 } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
204 break; 211 break;
205 case IOPRIO_WHO_USER: 212 case IOPRIO_WHO_USER:
213 uid = make_kuid(current_user_ns(), who);
206 if (!who) 214 if (!who)
207 user = current_user(); 215 user = current_user();
208 else 216 else
209 user = find_user(who); 217 user = find_user(uid);
210 218
211 if (!user) 219 if (!user)
212 break; 220 break;
213 221
214 do_each_thread(g, p) { 222 do_each_thread(g, p) {
215 if (__task_cred(p)->uid != user->uid) 223 const struct cred *tcred = __task_cred(p);
224 kuid_t tcred_uid = make_kuid(tcred->user_ns, tcred->uid);
225 if (!uid_eq(tcred_uid, user->uid))
216 continue; 226 continue;
217 tmpio = get_task_ioprio(p); 227 tmpio = get_task_ioprio(p);
218 if (tmpio < 0) 228 if (tmpio < 0)