From 546c5fc505e9252280e181ec127664b2ffaebf39 Mon Sep 17 00:00:00 2001 From: Lu Jialin Date: Wed, 3 Feb 2021 15:10:31 +0800 Subject: [PATCH] cgroup: Return ERSCH when add Z process into task hulk inclusion category: bugfix Bugzilla: 47951 CVE: NA -------------------------- When echo a Z process into tasks, it should return -ERSCH instead of 0. Signed-off-by: Lu Jialin Reviewed-by: Xiu Jianfeng Signed-off-by: Zheng Zengkai --- kernel/cgroup/cgroup.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 2a004d837524..a581ce0e058c 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2697,6 +2697,7 @@ int cgroup_migrate_prepare_dst(struct cgroup_mgctx *mgctx) int cgroup_migrate(struct task_struct *leader, bool threadgroup, struct cgroup_mgctx *mgctx) { + int err = 0; struct task_struct *task; /* @@ -2709,13 +2710,16 @@ int cgroup_migrate(struct task_struct *leader, bool threadgroup, task = leader; do { cgroup_migrate_add_task(task, mgctx); - if (!threadgroup) + if (!threadgroup) { + if (task->flags & PF_EXITING) + err = -ESRCH; break; + } } while_each_thread(leader, task); rcu_read_unlock(); spin_unlock_irq(&css_set_lock); - return cgroup_migrate_execute(mgctx); + return err ? err : cgroup_migrate_execute(mgctx); } /** -- GitLab