Merge remote-tracking branch 'lsk/v3.10/topic/aosp' into linux-linaro-lsk-android
[firefly-linux-kernel-4.4.55.git] / kernel / cgroup.c
index cd1c303214f32c20672538283d1e053323abb65c..e646e870ec5fbe6929e582866c313cd513a5ac0b 100644 (file)
@@ -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