From 703920c14a3caa66862bd12b88a7ed6460ebef6b Mon Sep 17 00:00:00 2001 From: Amit Pundir Date: Mon, 21 Dec 2015 16:01:10 +0530 Subject: [PATCH] cgroup: refactor allow_attach handler for 4.4 Refactor *allow_attach() handler to align it with the changes from mainline commit 1f7dd3e5a6e4 "cgroup: fix handling of multi-destination migration from subtree_control enabling". Signed-off-by: Amit Pundir --- include/linux/cgroup-defs.h | 3 +-- include/linux/cgroup.h | 6 ++---- kernel/cgroup.c | 7 ++++--- mm/memcontrol.c | 8 +++----- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/include/linux/cgroup-defs.h b/include/linux/cgroup-defs.h index f3425da070e1..4a4eea01956c 100644 --- a/include/linux/cgroup-defs.h +++ b/include/linux/cgroup-defs.h @@ -422,8 +422,7 @@ struct cgroup_subsys { void (*css_reset)(struct cgroup_subsys_state *css); void (*css_e_css_changed)(struct cgroup_subsys_state *css); - int (*allow_attach)(struct cgroup_subsys_state *css, - struct cgroup_taskset *tset); + int (*allow_attach)(struct cgroup_taskset *tset); int (*can_attach)(struct cgroup_taskset *tset); void (*cancel_attach)(struct cgroup_taskset *tset); void (*attach)(struct cgroup_taskset *tset); diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 1cb19feddcb2..70358b9f5a7a 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -535,8 +535,7 @@ static inline void pr_cont_cgroup_path(struct cgroup *cgrp) * running as root. * Returns 0 if this is allowed, or -EACCES otherwise. */ -int subsys_cgroup_allow_attach(struct cgroup_subsys_state *css, - struct cgroup_taskset *tset); +int subsys_cgroup_allow_attach(struct cgroup_taskset *tset); #else /* !CONFIG_CGROUPS */ @@ -563,8 +562,7 @@ static inline void cgroup_free(struct task_struct *p) {} static inline int cgroup_init_early(void) { return 0; } static inline int cgroup_init(void) { return 0; } -static inline int subsys_cgroup_allow_attach(struct cgroup_subsys_state *css, - void *tset) +static inline int subsys_cgroup_allow_attach(void *tset) { return -EINVAL; } diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7fd423e55046..a57b7c86871c 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c @@ -2663,15 +2663,16 @@ static int cgroup_attach_task(struct cgroup *dst_cgrp, return ret; } -int subsys_cgroup_allow_attach(struct cgroup_subsys_state *css, struct cgroup_taskset *tset) +int subsys_cgroup_allow_attach(struct cgroup_taskset *tset) { const struct cred *cred = current_cred(), *tcred; struct task_struct *task; + struct cgroup_subsys_state *css; if (capable(CAP_SYS_NICE)) return 0; - cgroup_taskset_for_each(task, tset) { + cgroup_taskset_for_each(task, css, tset) { tcred = __task_cred(task); if (current != task && !uid_eq(cred->euid, tcred->uid) && @@ -2690,7 +2691,7 @@ static int cgroup_allow_attach(struct cgroup *cgrp, struct cgroup_taskset *tset) for_each_css(css, i, cgrp) { if (css->ss->allow_attach) { - ret = css->ss->allow_attach(css, tset); + ret = css->ss->allow_attach(tset); if (ret) return ret; } else { diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 83b222be7d37..e0e486323bf1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4878,10 +4878,9 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset) return ret; } -static int mem_cgroup_allow_attach(struct cgroup_subsys_state *css, - struct cgroup_taskset *tset) +static int mem_cgroup_allow_attach(struct cgroup_taskset *tset) { - return subsys_cgroup_allow_attach(css, tset); + return subsys_cgroup_allow_attach(tset); } static void mem_cgroup_cancel_attach(struct cgroup_taskset *tset) @@ -5045,8 +5044,7 @@ static int mem_cgroup_can_attach(struct cgroup_taskset *tset) { return 0; } -static int mem_cgroup_allow_attach(struct cgroup_subsys_state *css, - struct cgroup_taskset *tset) +static int mem_cgroup_allow_attach(struct cgroup_taskset *tset) { return 0; } -- 2.34.1