summaryrefslogtreecommitdiff
path: root/kernel/sched.c
diff options
context:
space:
mode:
authorSan Mehat <san@google.com>2009-05-21 14:10:06 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:38:10 -0800
commite84e563ae2ed297d5d35d8da3b7302384ff6c7da (patch)
tree5fa760f95deef258d1158228b5c2f5855824c0eb /kernel/sched.c
parentbc4169bdee5099056af585ccecb8f3639f5e212c (diff)
cgroup: Add generic cgroup subsystem permission checks.
Rather than using explicit euid == 0 checks when trying to move tasks into a cgroup via CFS, move permission checks into each specific cgroup subsystem. If a subsystem does not specify a 'can_attach' handler, then we fall back to doing our checks the old way. This way non-root processes can add arbitrary processes to a cgroup if all the registered subsystems on that cgroup agree. Also change explicit euid == 0 check to CAP_SYS_ADMIN Signed-off-by: San Mehat <san@google.com>
Diffstat (limited to 'kernel/sched.c')
-rw-r--r--kernel/sched.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/kernel/sched.c b/kernel/sched.c
index d0f600c94843..279d2552dae7 100644
--- a/kernel/sched.c
+++ b/kernel/sched.c
@@ -8967,6 +8967,15 @@ cpu_cgroup_destroy(struct cgroup_subsys *ss, struct cgroup *cgrp)
static int
cpu_cgroup_can_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
{
+ if ((current != tsk) && (!capable(CAP_SYS_NICE))) {
+ const struct cred *cred = current_cred(), *tcred;
+
+ tcred = __task_cred(tsk);
+
+ if (cred->euid != tcred->uid && cred->euid != tcred->suid)
+ return -EPERM;
+ }
+
#ifdef CONFIG_RT_GROUP_SCHED
if (!sched_rt_can_attach(cgroup_tg(cgrp), tsk))
return -EINVAL;