diff options
author | Dhaval Giani <dhaval@linux.vnet.ibm.com> | 2009-02-27 04:43:54 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-27 05:11:53 -0500 |
commit | 54e991242850edc8c53f71fa5aa3ba7a93ce38f5 (patch) | |
tree | 7f136214aab690a8ee4a294ca9c1a7e01de0dc49 /kernel/sched.c | |
parent | cac64d00c256e65776d575e82aaf540632b66178 (diff) |
sched: don't allow setuid to succeed if the user does not have rt bandwidth
Impact: fix hung task with certain (non-default) rt-limit settings
Corey Hickey reported that on using setuid to change the uid of a
rt process, the process would be unkillable and not be running.
This is because there was no rt runtime for that user group. Add
in a check to see if a user can attach an rt task to its task group.
On failure, return EINVAL, which is also returned in
CONFIG_CGROUP_SCHED.
Reported-by: Corey Hickey <bugfood-ml@fatooh.org>
Signed-off-by: Dhaval Giani <dhaval@linux.vnet.ibm.com>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r-- | kernel/sched.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/sched.c b/kernel/sched.c index c3baa9653d1d..8e2558c2ba67 100644 --- a/kernel/sched.c +++ b/kernel/sched.c | |||
@@ -9224,6 +9224,16 @@ static int sched_rt_global_constraints(void) | |||
9224 | 9224 | ||
9225 | return ret; | 9225 | return ret; |
9226 | } | 9226 | } |
9227 | |||
9228 | int sched_rt_can_attach(struct task_group *tg, struct task_struct *tsk) | ||
9229 | { | ||
9230 | /* Don't accept realtime tasks when there is no way for them to run */ | ||
9231 | if (rt_task(tsk) && tg->rt_bandwidth.rt_runtime == 0) | ||
9232 | return 0; | ||
9233 | |||
9234 | return 1; | ||
9235 | } | ||
9236 | |||
9227 | #else /* !CONFIG_RT_GROUP_SCHED */ | 9237 | #else /* !CONFIG_RT_GROUP_SCHED */ |
9228 | static int sched_rt_global_constraints(void) | 9238 | static int sched_rt_global_constraints(void) |
9229 | { | 9239 | { |
@@ -9317,8 +9327,7 @@ cpu_cgroup_can_attach(struct cgroup_subsys *ss, struct cgroup *cgrp, | |||
9317 | struct task_struct *tsk) | 9327 | struct task_struct *tsk) |
9318 | { | 9328 | { |
9319 | #ifdef CONFIG_RT_GROUP_SCHED | 9329 | #ifdef CONFIG_RT_GROUP_SCHED |
9320 | /* Don't accept realtime tasks when there is no way for them to run */ | 9330 | if (!sched_rt_can_attach(cgroup_tg(cgrp), tsk)) |
9321 | if (rt_task(tsk) && cgroup_tg(cgrp)->rt_bandwidth.rt_runtime == 0) | ||
9322 | return -EINVAL; | 9331 | return -EINVAL; |
9323 | #else | 9332 | #else |
9324 | /* We don't support RT-tasks being in separate groups */ | 9333 | /* We don't support RT-tasks being in separate groups */ |