Revert "cgroup: Add generic cgroup subsystem permission checks."
author黄涛 <huangtao@rock-chips.com>
Sat, 30 Jul 2011 14:45:02 +0000 (22:45 +0800)
committer黄涛 <huangtao@rock-chips.com>
Sat, 30 Jul 2011 14:45:02 +0000 (22:45 +0800)
This reverts commit 5038d42d2e60c855cf5b097197d95adaa1269d32.

kernel/cgroup.c
kernel/cgroup_freezer.c
kernel/cpuset.c
kernel/sched.c

index 455689fd19715bc905a3f826bd4a329dbc9a1db8..0249f4be9b5cf8fefe9885b6093911746d7a9cdd 100644 (file)
@@ -51,7 +51,6 @@
 #include <linux/pid_namespace.h>
 #include <linux/idr.h>
 #include <linux/vmalloc.h> /* TODO: replace with more sophisticated array */
-#include <linux/capability.h>
 
 #include <asm/atomic.h>
 
@@ -1556,15 +1555,6 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
                        retval = ss->can_attach(ss, cgrp, tsk, false);
                        if (retval)
                                return retval;
-               } else if (!capable(CAP_SYS_ADMIN)) {
-                       const struct cred *cred = current_cred(), *tcred;
-
-                       /* No can_attach() - check perms generically */
-                       tcred = __task_cred(tsk);
-                       if (cred->euid != tcred->uid &&
-                           cred->euid != tcred->suid) {
-                               return -EACCES;
-                       }
                }
        }
 
@@ -1621,6 +1611,7 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk)
 static int attach_task_by_pid(struct cgroup *cgrp, u64 pid)
 {
        struct task_struct *tsk;
+       const struct cred *cred = current_cred(), *tcred;
        int ret;
 
        if (pid) {
@@ -1630,6 +1621,14 @@ static int attach_task_by_pid(struct cgroup *cgrp, u64 pid)
                        rcu_read_unlock();
                        return -ESRCH;
                }
+
+               tcred = __task_cred(tsk);
+               if (cred->euid &&
+                   cred->euid != tcred->uid &&
+                   cred->euid != tcred->suid) {
+                       rcu_read_unlock();
+                       return -EACCES;
+               }
                get_task_struct(tsk);
                rcu_read_unlock();
        } else {
index 67b155f65a6c944b100a684d651b7a2b65fc3e17..59e9ef6aab4002e1d99170f50156e733e8f46343 100644 (file)
@@ -163,14 +163,6 @@ static int freezer_can_attach(struct cgroup_subsys *ss,
 {
        struct freezer *freezer;
 
-       if ((current != task) && (!capable(CAP_SYS_ADMIN))) {
-               const struct cred *cred = current_cred(), *tcred;
-
-               tcred = __task_cred(task);
-               if (cred->euid != tcred->uid && cred->euid != tcred->suid)
-                       return -EPERM;
-       }
-
        /*
         * Anything frozen can't move or be moved to/from.
         *
index 2b637ca37be4b82aea0d7bb3dfbe9cf04d386b45..b5cb469d25456b03292d27e22ece4508ddba1ca2 100644 (file)
@@ -1330,13 +1330,6 @@ static int cpuset_can_attach(struct cgroup_subsys *ss, struct cgroup *cont,
        int ret;
        struct cpuset *cs = cgroup_cs(cont);
 
-       if ((current != task) && (!capable(CAP_SYS_ADMIN))) {
-               const struct cred *cred = current_cred(), *tcred;
-
-               if (cred->euid != tcred->uid && cred->euid != tcred->suid)
-                       return -EPERM;
-       }
        if (cpumask_empty(cs->cpus_allowed) || nodes_empty(cs->mems_allowed))
                return -ENOSPC;
 
index 117b2b4ebbafd2dee46bdae890ec9bfe7566af29..9f11c6c784154725068fdbeee135c1d616eadf1b 100644 (file)
@@ -10418,15 +10418,6 @@ 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;