kernel/cgroup/cgroup-v1.c | 2 ++ 1 file changed, 2 insertions(+)
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@syzkaller.appspotmail.com>
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Fixes: 4f7e7236435ca0ab ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
---
Waiting for test result from syzbot. Should we remove "static" from
cgroup_attach_lock() and call from cgroup_attach_task_all() ?
kernel/cgroup/cgroup-v1.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index 2ade21b54dc4..ff6a8099eb2a 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -59,6 +59,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
int retval = 0;
mutex_lock(&cgroup_mutex);
+ cpus_read_lock();
percpu_down_write(&cgroup_threadgroup_rwsem);
for_each_root(root) {
struct cgroup *from_cgrp;
@@ -72,6 +73,7 @@ int cgroup_attach_task_all(struct task_struct *from, struct task_struct *tsk)
break;
}
percpu_up_write(&cgroup_threadgroup_rwsem);
+ cpus_read_unlock();
mutex_unlock(&cgroup_mutex);
return retval;
--
2.18.4
On Thu, Aug 25, 2022 at 05:38:38PM +0900, Tetsuo Handa wrote:
> 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@syzkaller.appspotmail.com>
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Fixes: 4f7e7236435ca0ab ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock() deadlock")
Applied to cgroup/for-6.0-fixes and sent pull request.
> Waiting for test result from syzbot. Should we remove "static" from
> cgroup_attach_lock() and call from cgroup_attach_task_all() ?
Yeah, that probably is better. Can you spin up a follow up patch?
Thanks.
--
tejun
© 2016 - 2026 Red Hat, Inc.