Patch "cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     cgroup-add-missing-cpus_read_lock-to-cgroup_attach_task_all.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From caixinchen1@xxxxxxxxxx Mon Mar 20 02:20:45 2023
From: Cai Xinchen <caixinchen1@xxxxxxxxxx>
Date: Mon, 20 Mar 2023 01:15:07 +0000
Subject: cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all()
To: <longman@xxxxxxxxxx>, <lizefan.x@xxxxxxxxxxxxx>, <tj@xxxxxxxxxx>, <hannes@xxxxxxxxxxx>, <gregkh@xxxxxxxxxxxxxxxxxxx>, <sashal@xxxxxxxxxx>
Cc: <mkoutny@xxxxxxxx>, <zhangqiao22@xxxxxxxxxx>, <juri.lelli@xxxxxxxxxx>, <penguin-kernel@xxxxxxxxxxxxxxxxxxx>, <stable@xxxxxxxxxxxxxxx>, <cgroups@xxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>
Message-ID: <20230320011507.129441-4-caixinchen1@xxxxxxxxxx>

From: Cai Xinchen <caixinchen1@xxxxxxxxxx>

From: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>

commit 43626dade36fa74d3329046f4ae2d7fdefe401c6 upstream.

syzbot is hitting percpu_rwsem_assert_held(&cpu_hotplug_lock) warning at
cpuset_attach() [1], for commit 4f7e7236435ca0ab ("cgroup: Fix
threadgroup_rwsem <-> cpus_read_lock() deadlock") missed that
cpuset_attach() is also called from cgroup_attach_task_all().
Add cpus_read_lock() like what cgroup_procs_write_start() does.

Link: https://syzkaller.appspot.com/bug?extid=29d3a3b4d86c8136ad9e [1]
Reported-by: syzbot <syzbot+29d3a3b4d86c8136ad9e@xxxxxxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx>
Fixes: 4f7e7236435ca0ab ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>
Signed-off-by: Cai Xinchen <caixinchen1@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 kernel/cgroup/cgroup-v1.c |    3 +++
 1 file changed, 3 insertions(+)

--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -13,6 +13,7 @@
 #include <linux/delayacct.h>
 #include <linux/pid_namespace.h>
 #include <linux/cgroupstats.h>
+#include <linux/cpu.h>
 
 #include <trace/events/cgroup.h>
 
@@ -55,6 +56,7 @@ int cgroup_attach_task_all(struct task_s
 	int retval = 0;
 
 	mutex_lock(&cgroup_mutex);
+	get_online_cpus();
 	percpu_down_write(&cgroup_threadgroup_rwsem);
 	for_each_root(root) {
 		struct cgroup *from_cgrp;
@@ -71,6 +73,7 @@ int cgroup_attach_task_all(struct task_s
 			break;
 	}
 	percpu_up_write(&cgroup_threadgroup_rwsem);
+	put_online_cpus();
 	mutex_unlock(&cgroup_mutex);
 
 	return retval;


Patches currently in stable-queue which might be from caixinchen1@xxxxxxxxxx are

queue-4.19/cgroup-cpuset-change-cpuset_rwsem-and-hotplug-lock-order.patch
queue-4.19/cgroup-fix-threadgroup_rwsem-cpus_read_lock-deadlock.patch
queue-4.19/cgroup-add-missing-cpus_read_lock-to-cgroup_attach_task_all.patch



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux