From: Greg Kroah-Hartman Date: Wed, 23 Feb 2022 18:11:07 +0000 (+0100) Subject: 5.10-stable patches X-Git-Tag: v4.9.304~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6686e0c577c8a8c7fc5151ab14373cce5e628ae3;p=thirdparty%2Fkernel%2Fstable-queue.git 5.10-stable patches added patches: cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch --- diff --git a/queue-5.10/cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch b/queue-5.10/cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch new file mode 100644 index 00000000000..0123f2a932e --- /dev/null +++ b/queue-5.10/cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch @@ -0,0 +1,62 @@ +From 05c7b7a92cc87ff8d7fde189d0fade250697573c Mon Sep 17 00:00:00 2001 +From: Zhang Qiao +Date: Fri, 21 Jan 2022 18:12:10 +0800 +Subject: cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +From: Zhang Qiao + +commit 05c7b7a92cc87ff8d7fde189d0fade250697573c upstream. + +As previously discussed(https://lkml.org/lkml/2022/1/20/51), +cpuset_attach() is affected with similar cpu hotplug race, +as follow scenario: + + cpuset_attach() cpu hotplug + --------------------------- ---------------------- + down_write(cpuset_rwsem) + guarantee_online_cpus() // (load cpus_attach) + sched_cpu_deactivate + set_cpu_active() + // will change cpu_active_mask + set_cpus_allowed_ptr(cpus_attach) + __set_cpus_allowed_ptr_locked() + // (if the intersection of cpus_attach and + cpu_active_mask is empty, will return -EINVAL) + up_write(cpuset_rwsem) + +To avoid races such as described above, protect cpuset_attach() call +with cpu_hotplug_lock. + +Fixes: be367d099270 ("cgroups: let ss->can_attach and ss->attach do whole threadgroups at a time") +Cc: stable@vger.kernel.org # v2.6.32+ +Reported-by: Zhao Gongyi +Signed-off-by: Zhang Qiao +Acked-by: Waiman Long +Reviewed-by: Michal Koutný +Signed-off-by: Tejun Heo +Signed-off-by: Greg Kroah-Hartman +--- + kernel/cgroup/cpuset.c | 2 ++ + 1 file changed, 2 insertions(+) + +--- a/kernel/cgroup/cpuset.c ++++ b/kernel/cgroup/cpuset.c +@@ -2212,6 +2212,7 @@ static void cpuset_attach(struct cgroup_ + cgroup_taskset_first(tset, &css); + cs = css_cs(css); + ++ cpus_read_lock(); + percpu_down_write(&cpuset_rwsem); + + /* prepare for attach */ +@@ -2267,6 +2268,7 @@ static void cpuset_attach(struct cgroup_ + wake_up(&cpuset_attach_wq); + + percpu_up_write(&cpuset_rwsem); ++ cpus_read_unlock(); + } + + /* The various types of files and directories in a cpuset file system */ diff --git a/queue-5.10/series b/queue-5.10/series new file mode 100644 index 00000000000..5ac931fd893 --- /dev/null +++ b/queue-5.10/series @@ -0,0 +1 @@ +cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch