X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=kernel%2Fcgroup.c;h=e646e870ec5fbe6929e582866c313cd513a5ac0b;hb=e8f1cafd746408478934b9c8b9e9e0d5f450906c;hp=cd1c303214f32c20672538283d1e053323abb65c;hpb=e84dcb80ef24eb9a2ac03506498e688fa7938718;p=firefly-linux-kernel-4.4.55.git diff --git a/kernel/cgroup.c b/kernel/cgroup.c index cd1c303214f3..e646e870ec5f 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2124,6 +2124,25 @@ static int cgroup_allow_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) return 0; } +int subsys_cgroup_allow_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) +{ + const struct cred *cred = current_cred(), *tcred; + struct task_struct *task; + + if (capable(CAP_SYS_NICE)) + return 0; + + cgroup_taskset_for_each(task, cgrp, tset) { + tcred = __task_cred(task); + + if (current != task && cred->euid != tcred->uid && + cred->euid != tcred->suid) + return -EACCES; + } + + return 0; +} + /* * Find the task_struct of the task to attach by vpid and pass it along to the * function to attach either it or all tasks in its threadgroup. Will lock