Files
android_kernel_xiaomi_sm8450/kernel/cgroup/cgroup.c
Tejun Heo d1e180148e BACKPORT: cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock
Bringing up a CPU may involve creating and destroying tasks which requires
read-locking threadgroup_rwsem, so threadgroup_rwsem nests inside
cpus_read_lock(). However, cpuset's ->attach(), which may be called with
thredagroup_rwsem write-locked, also wants to disable CPU hotplug and
acquires cpus_read_lock(), leading to a deadlock.

Fix it by guaranteeing that ->attach() is always called with CPU hotplug
disabled and removing cpus_read_lock() call from cpuset_attach().

Bug: 242685775
Change-Id: Ib14746f8e361eac8a1cfb88ae920488d1155d904
Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-and-tested-by: Imran Khan <imran.f.khan@oracle.com>
Reported-and-tested-by: Xuewen Yan <xuewen.yan@unisoc.com>
Fixes: 05c7b7a92cc8 ("cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug")
Cc: stable@vger.kernel.org # v5.17+
Link: https://lore.kernel.org/lkml/YvrWaml3F+x9Dk+T@slm.duckdns.org/
Link: https://lore.kernel.org/lkml/20220705123705.764-1-xuewen.yan@unisoc.com/
(cherry picked from commit 4f7e7236435ca0abe005c674ebd6892c6e83aeb3
https://git.kernel.org/pub/scm/linux/kernel/git/tj/cgroup.git for-6.0-fixes)
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
2022-08-19 18:44:41 +00:00

178 KiB