From: Greg Kroah-Hartman Date: Tue, 13 Sep 2022 13:58:20 +0000 (+0200) Subject: fix up queue-5.4/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch X-Git-Tag: v5.19.9~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6d6eeac3338be635343f038d357c5eb431084d7;p=thirdparty%2Fkernel%2Fstable-queue.git fix up queue-5.4/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch --- diff --git a/queue-5.4/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch b/queue-5.4/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch index db8192a85b3..8a9bccaa67c 100644 --- a/queue-5.4/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch +++ b/queue-5.4/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch @@ -23,19 +23,24 @@ Fixes: 05c7b7a92cc8 ("cgroup/cpuset: Fix a race between cpuset_attach() and cpu Cc: stable@vger.kernel.org # v5.17+ Signed-off-by: Sasha Levin --- - kernel/cgroup/cgroup.c | 77 +++++++++++++++++++++++++++++------------- - kernel/cgroup/cpuset.c | 3 +- - 2 files changed, 55 insertions(+), 25 deletions(-) + kernel/cgroup/cgroup.c | 78 ++++++++++++++++++++++++++++++++++--------------- + kernel/cgroup/cpuset.c | 3 - + 2 files changed, 56 insertions(+), 25 deletions(-) -diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c -index c2af09b4bca62..43f9bfedd890c 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c -@@ -2376,6 +2376,47 @@ int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen) - } +@@ -30,6 +30,7 @@ + + #include "cgroup-internal.h" + ++#include + #include + #include + #include +@@ -2377,6 +2378,47 @@ int task_cgroup_path(struct task_struct EXPORT_SYMBOL_GPL(task_cgroup_path); -+/** + /** + * cgroup_attach_lock - Lock for ->attach() + * @lock_threadgroup: whether to down_write cgroup_threadgroup_rwsem + * @@ -76,10 +81,11 @@ index c2af09b4bca62..43f9bfedd890c 100644 + cpus_read_unlock(); +} + - /** ++/** * cgroup_migrate_add_task - add a migration target task to a migration context * @task: target task -@@ -2857,8 +2898,7 @@ int cgroup_attach_task(struct cgroup *dst_cgrp, struct task_struct *leader, + * @mgctx: target migration context +@@ -2857,8 +2899,7 @@ int cgroup_attach_task(struct cgroup *ds } struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup, @@ -89,7 +95,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 { struct task_struct *tsk; pid_t pid; -@@ -2875,12 +2915,8 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup, +@@ -2875,12 +2916,8 @@ struct task_struct *cgroup_procs_write_s * Therefore, we can skip the global lock. */ lockdep_assert_held(&cgroup_mutex); @@ -104,7 +110,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 rcu_read_lock(); if (pid) { -@@ -2911,17 +2947,14 @@ struct task_struct *cgroup_procs_write_start(char *buf, bool threadgroup, +@@ -2911,17 +2948,14 @@ struct task_struct *cgroup_procs_write_s goto out_unlock_rcu; out_unlock_threadgroup: @@ -125,7 +131,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 { struct cgroup_subsys *ss; int ssid; -@@ -2929,8 +2962,8 @@ void cgroup_procs_write_finish(struct task_struct *task, bool locked) +@@ -2929,8 +2963,8 @@ void cgroup_procs_write_finish(struct ta /* release reference from cgroup_procs_write_start() */ put_task_struct(task); @@ -136,7 +142,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 for_each_subsys(ss, ssid) if (ss->post_attach) ss->post_attach(); -@@ -3007,8 +3040,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp) +@@ -3007,8 +3041,7 @@ static int cgroup_update_dfl_csses(struc * write-locking can be skipped safely. */ has_tasks = !list_empty(&mgctx.preloaded_src_csets); @@ -146,7 +152,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 /* NULL dst indicates self on default hierarchy */ ret = cgroup_migrate_prepare_dst(&mgctx); -@@ -3029,8 +3061,7 @@ static int cgroup_update_dfl_csses(struct cgroup *cgrp) +@@ -3029,8 +3062,7 @@ static int cgroup_update_dfl_csses(struc ret = cgroup_migrate_execute(&mgctx); out_finish: cgroup_migrate_finish(&mgctx); @@ -156,7 +162,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 return ret; } -@@ -4859,13 +4890,13 @@ static ssize_t cgroup_procs_write(struct kernfs_open_file *of, +@@ -4859,13 +4891,13 @@ static ssize_t cgroup_procs_write(struct struct task_struct *task; const struct cred *saved_cred; ssize_t ret; @@ -172,7 +178,7 @@ index c2af09b4bca62..43f9bfedd890c 100644 ret = PTR_ERR_OR_ZERO(task); if (ret) goto out_unlock; -@@ -4891,7 +4922,7 @@ static ssize_t cgroup_procs_write(struct kernfs_open_file *of, +@@ -4891,7 +4923,7 @@ static ssize_t cgroup_procs_write(struct ret = cgroup_attach_task(dst_cgrp, task, true); out_finish: @@ -181,11 +187,9 @@ index c2af09b4bca62..43f9bfedd890c 100644 out_unlock: cgroup_kn_unlock(of->kn); -diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c -index b02eca235ba3f..9ba94a9a67aa4 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c -@@ -2204,7 +2204,7 @@ static void cpuset_attach(struct cgroup_taskset *tset) +@@ -2204,7 +2204,7 @@ static void cpuset_attach(struct cgroup_ cgroup_taskset_first(tset, &css); cs = css_cs(css); @@ -194,7 +198,7 @@ index b02eca235ba3f..9ba94a9a67aa4 100644 percpu_down_write(&cpuset_rwsem); /* prepare for attach */ -@@ -2260,7 +2260,6 @@ static void cpuset_attach(struct cgroup_taskset *tset) +@@ -2260,7 +2260,6 @@ static void cpuset_attach(struct cgroup_ wake_up(&cpuset_attach_wq); percpu_up_write(&cpuset_rwsem); @@ -202,6 +206,3 @@ index b02eca235ba3f..9ba94a9a67aa4 100644 } /* The various types of files and directories in a cpuset file system */ --- -2.35.1 -