cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock
mainline inclusion from mainline-v6.0-rc3 commit 4f7e7236 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6L46J CVE: NA Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4f7e7236435ca0abe005c674ebd6892c6e83aeb3 -------------------------------- 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(). Signed-off-by: NTejun Heo <tj@kernel.org> Reviewed-and-tested-by: NImran Khan <imran.f.khan@oracle.com> Reported-and-tested-by: NXuewen Yan <xuewen.yan@unisoc.com> Fixes: 05c7b7a9 ("cgroup/cpuset: Fix a race between cpuset_attach() and cpu hotplug") Cc: stable@vger.kernel.org # v5.17+ conflict: kernel/cgroup/cgroup.c kernel/cgroup/cpuset.c Signed-off-by: NCai Xinchen <caixinchen1@huawei.com> Reviewed-by: NWang Weiyang <wangweiyang2@huawei.com> Reviewed-by: NXiu Jianfeng <xiujianfeng@huawei.com> Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
Showing
想要评论请 注册 或 登录