]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.14-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 18:03:03 +0000 (19:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Feb 2022 18:03:03 +0000 (19:03 +0100)
added patches:
cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch

queue-4.14/cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch [new file with mode: 0644]
queue-4.14/series
queue-4.9/series [new file with mode: 0644]

diff --git a/queue-4.14/cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch b/queue-4.14/cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch
new file mode 100644 (file)
index 0000000..fffa3b5
--- /dev/null
@@ -0,0 +1,62 @@
+From 05c7b7a92cc87ff8d7fde189d0fade250697573c Mon Sep 17 00:00:00 2001
+From: Zhang Qiao <zhangqiao22@huawei.com>
+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 <zhangqiao22@huawei.com>
+
+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 <zhaogongyi@huawei.com>
+Signed-off-by: Zhang Qiao <zhangqiao22@huawei.com>
+Acked-by: Waiman Long <longman@redhat.com>
+Reviewed-by: Michal Koutný <mkoutny@suse.com>
+Signed-off-by: Tejun Heo <tj@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ kernel/cgroup/cpuset.c |    2 ++
+ 1 file changed, 2 insertions(+)
+
+--- a/kernel/cgroup/cpuset.c
++++ b/kernel/cgroup/cpuset.c
+@@ -1532,6 +1532,7 @@ static void cpuset_attach(struct cgroup_
+       cgroup_taskset_first(tset, &css);
+       cs = css_cs(css);
++      cpus_read_lock();
+       mutex_lock(&cpuset_mutex);
+       /* prepare for attach */
+@@ -1587,6 +1588,7 @@ static void cpuset_attach(struct cgroup_
+               wake_up(&cpuset_attach_wq);
+       mutex_unlock(&cpuset_mutex);
++      cpus_read_unlock();
+ }
+ /* The various types of files and directories in a cpuset file system */
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..5ac931fd89396041ef6f36636a079c488f68c98f 100644 (file)
@@ -0,0 +1 @@
+cgroup-cpuset-fix-a-race-between-cpuset_attach-and-cpu-hotplug.patch
diff --git a/queue-4.9/series b/queue-4.9/series
new file mode 100644 (file)
index 0000000..e69de29