memcg: add permission check
Use the 'allow_attach' handler for the 'mem' cgroup to allow non-root processes to add arbitrary processes to a 'mem' cgroup if it has the CAP_SYS_NICE capability set. Bug: 18260435 Change-Id: If7d37bf90c1544024c4db53351adba6a64966250 Signed-off-by: Rom Lemarchand <romlem@android.com>
This commit is contained in:
parent
6809864a2c
commit
e6f5c0c0ec
1 changed files with 12 additions and 0 deletions
|
@ -4878,6 +4878,12 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int mem_cgroup_allow_attach(struct cgroup_subsys_state *css,
|
||||||
|
struct cgroup_taskset *tset)
|
||||||
|
{
|
||||||
|
return subsys_cgroup_allow_attach(css->cgroup, tset);
|
||||||
|
}
|
||||||
|
|
||||||
static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
|
static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
|
||||||
{
|
{
|
||||||
if (mc.to)
|
if (mc.to)
|
||||||
|
@ -5039,6 +5045,11 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
static int mem_cgroup_allow_attach(struct cgroup_subsys_state *css,
|
||||||
|
struct cgroup_taskset *tset)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
|
static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -5222,6 +5233,7 @@ struct cgroup_subsys memory_cgrp_subsys = {
|
||||||
.can_attach = mem_cgroup_can_attach,
|
.can_attach = mem_cgroup_can_attach,
|
||||||
.cancel_attach = mem_cgroup_cancel_attach,
|
.cancel_attach = mem_cgroup_cancel_attach,
|
||||||
.attach = mem_cgroup_move_task,
|
.attach = mem_cgroup_move_task,
|
||||||
|
.allow_attach = mem_cgroup_allow_attach,
|
||||||
.bind = mem_cgroup_bind,
|
.bind = mem_cgroup_bind,
|
||||||
.dfl_cftypes = memory_files,
|
.dfl_cftypes = memory_files,
|
||||||
.legacy_cftypes = mem_cgroup_legacy_files,
|
.legacy_cftypes = mem_cgroup_legacy_files,
|
||||||
|
|
Loading…
Add table
Reference in a new issue