diff options
Diffstat (limited to 'fs/ioprio.c')
-rw-r--r-- | fs/ioprio.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/fs/ioprio.c b/fs/ioprio.c index 0f1b9515213b..e50170ca7c33 100644 --- a/fs/ioprio.c +++ b/fs/ioprio.c | |||
@@ -37,8 +37,8 @@ int set_task_ioprio(struct task_struct *task, int ioprio) | |||
37 | 37 | ||
38 | rcu_read_lock(); | 38 | rcu_read_lock(); |
39 | tcred = __task_cred(task); | 39 | tcred = __task_cred(task); |
40 | if (tcred->uid != cred->euid && | 40 | if (!uid_eq(tcred->uid, cred->euid) && |
41 | tcred->uid != cred->uid && !capable(CAP_SYS_NICE)) { | 41 | !uid_eq(tcred->uid, cred->uid) && !capable(CAP_SYS_NICE)) { |
42 | rcu_read_unlock(); | 42 | rcu_read_unlock(); |
43 | return -EPERM; | 43 | return -EPERM; |
44 | } | 44 | } |
@@ -50,7 +50,7 @@ int set_task_ioprio(struct task_struct *task, int ioprio) | |||
50 | 50 | ||
51 | ioc = get_task_io_context(task, GFP_ATOMIC, NUMA_NO_NODE); | 51 | ioc = get_task_io_context(task, GFP_ATOMIC, NUMA_NO_NODE); |
52 | if (ioc) { | 52 | if (ioc) { |
53 | ioc_ioprio_changed(ioc, ioprio); | 53 | ioc->ioprio = ioprio; |
54 | put_io_context(ioc); | 54 | put_io_context(ioc); |
55 | } | 55 | } |
56 | 56 | ||
@@ -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,19 @@ 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 | if (!uid_eq(task_uid(p), uid)) |
123 | continue; | 127 | continue; |
124 | ret = set_task_ioprio(p, ioprio); | 128 | ret = set_task_ioprio(p, ioprio); |
125 | if (ret) | 129 | if (ret) |
@@ -174,6 +178,7 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) | |||
174 | struct task_struct *g, *p; | 178 | struct task_struct *g, *p; |
175 | struct user_struct *user; | 179 | struct user_struct *user; |
176 | struct pid *pgrp; | 180 | struct pid *pgrp; |
181 | kuid_t uid; | ||
177 | int ret = -ESRCH; | 182 | int ret = -ESRCH; |
178 | int tmpio; | 183 | int tmpio; |
179 | 184 | ||
@@ -203,16 +208,17 @@ SYSCALL_DEFINE2(ioprio_get, int, which, int, who) | |||
203 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); | 208 | } while_each_pid_thread(pgrp, PIDTYPE_PGID, p); |
204 | break; | 209 | break; |
205 | case IOPRIO_WHO_USER: | 210 | case IOPRIO_WHO_USER: |
211 | uid = make_kuid(current_user_ns(), who); | ||
206 | if (!who) | 212 | if (!who) |
207 | user = current_user(); | 213 | user = current_user(); |
208 | else | 214 | else |
209 | user = find_user(who); | 215 | user = find_user(uid); |
210 | 216 | ||
211 | if (!user) | 217 | if (!user) |
212 | break; | 218 | break; |
213 | 219 | ||
214 | do_each_thread(g, p) { | 220 | do_each_thread(g, p) { |
215 | if (__task_cred(p)->uid != user->uid) | 221 | if (!uid_eq(task_uid(p), user->uid)) |
216 | continue; | 222 | continue; |
217 | tmpio = get_task_ioprio(p); | 223 | tmpio = get_task_ioprio(p); |
218 | if (tmpio < 0) | 224 | if (tmpio < 0) |