diff options
| author | San Mehat <san@google.com> | 2009-05-21 14:10:06 -0700 |
|---|---|---|
| committer | Colin Cross <ccross@android.com> | 2010-09-29 17:49:18 -0700 |
| commit | c316a1d4a0867c767cda23397e634e28905a8cc7 (patch) | |
| tree | d38b560d4fdac7565eee2450259e8f78e78fcfdb /kernel/cgroup_freezer.c | |
| parent | b8aab015cd2af37c45d95967de1122825ce4d90d (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/cgroup_freezer.c')
| -rw-r--r-- | kernel/cgroup_freezer.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/kernel/cgroup_freezer.c b/kernel/cgroup_freezer.c index ce71ed53e88f..8e4c614d9553 100644 --- a/kernel/cgroup_freezer.c +++ b/kernel/cgroup_freezer.c @@ -172,6 +172,14 @@ 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. * |
