From 55ab7be4f79903e7448d03ffbd2b6d59daad2ca1 Mon Sep 17 00:00:00 2001 From: Rom Lemarchand Date: Fri, 7 Nov 2014 12:48:17 -0800 Subject: cgroup: refactor allow_attach function into common code move cpu_cgroup_allow_attach to a common subsys_cgroup_allow_attach. This allows any process with CAP_SYS_NICE to move tasks across cgroups if they use this function as their allow_attach handler. Bug: 18260435 Change-Id: I6bb4933d07e889d0dc39e33b4e71320c34a2c90f Signed-off-by: Rom Lemarchand Signed-off-by: Chatur27 --- include/linux/cgroup.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include/linux/cgroup.h') diff --git a/include/linux/cgroup.h b/include/linux/cgroup.h index 55d3ff0c5c03..e6ab2f1e6f8b 100644 --- a/include/linux/cgroup.h +++ b/include/linux/cgroup.h @@ -623,6 +623,17 @@ static inline void cgroup_kthread_ready(void) current->no_cgroup_migration = 0; } +/* + * Default Android check for whether the current process is allowed to move a + * task across cgroups, either because CAP_SYS_NICE is set or because the uid + * of the calling process is the same as the moved task or because we are + * 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); + + #else /* !CONFIG_CGROUPS */ struct cgroup_subsys_state; @@ -645,6 +656,11 @@ static inline int cgroup_init(void) { return 0; } static inline void cgroup_init_kthreadd(void) {} static inline void cgroup_kthread_ready(void) {} +static inline int subsys_cgroup_allow_attach(struct cgroup_subsys_state *css, + struct cgroup_taskset *tset) +{ + return 0; +} #endif /* !CONFIG_CGROUPS */ /* -- cgit v1.2.3