diff options
Diffstat (limited to 'kernel/cgroup.c')
-rw-r--r-- | kernel/cgroup.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 25c7eb52de1a..aab77936c064 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -57,6 +57,7 @@ #include <linux/vmalloc.h> /* TODO: replace with more sophisticated array */ #include <linux/eventfd.h> #include <linux/poll.h> +#include <linux/capability.h> #include <asm/atomic.h> @@ -1782,6 +1783,14 @@ int cgroup_attach_task(struct cgroup *cgrp, struct task_struct *tsk) */ failed_ss = ss; goto out; + } 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; } } } @@ -1879,7 +1888,6 @@ EXPORT_SYMBOL_GPL(cgroup_attach_task_all); 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) { @@ -1889,14 +1897,6 @@ 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 { |