cgroup: refactor allow_attach handler for 4.4

Refactor *allow_attach() handler to align it with the changes
from mainline commit 1f7dd3e5a6 "cgroup: fix handling of
multi-destination migration from subtree_control enabling".

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
This commit is contained in:
Amit Pundir 2015-12-21 16:01:10 +05:30 committed by John Stultz
parent 69db8fca42
commit 703920c14a
4 changed files with 10 additions and 14 deletions

View File

@ -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);

View File

@ -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;
}

View File

@ -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 {

View File

@ -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;
}