From nobody Thu Apr 2 19:56:26 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9F1B6ECAAD8 for ; Wed, 21 Sep 2022 16:02:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232149AbiIUQCx (ORCPT ); Wed, 21 Sep 2022 12:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232670AbiIUQAO (ORCPT ); Wed, 21 Sep 2022 12:00:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2EEAA1D37; Wed, 21 Sep 2022 08:53:47 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 723F76313C; Wed, 21 Sep 2022 15:52:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 666D8C433C1; Wed, 21 Sep 2022 15:52:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1663775529; bh=mkaX5RuDhnmFM+UEDvJxrlMxt/orYZHMo1XPm8F3D9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5JpB7OrYE/QRXjdy3u53y9DkoCaZh4ey9FMurXHCbQQUVFI21oXLCYd0PUm3U79F UROhqzJAwxw9bKS4i3P1OdAp2R6pOD14pITvN8zSJ40UoO4yopY4TYBPypYZYVVeY/ xnhr9M7ewNsZkDq1JCjUs9/T+YtXzx4FO/NYKxUM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Tetsuo Handa , Tejun Heo Subject: [PATCH 5.10 38/39] cgroup: Add missing cpus_read_lock() to cgroup_attach_task_all() Date: Wed, 21 Sep 2022 17:46:43 +0200 Message-Id: <20220921153646.952587114@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220921153645.663680057@linuxfoundation.org> References: <20220921153645.663680057@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Tetsuo Handa 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=3D29d3a3b4d86c8136ad9e [1] Reported-by: syzbot Signed-off-by: Tetsuo Handa Fixes: 4f7e7236435ca0ab ("cgroup: Fix threadgroup_rwsem <-> cpus_read_lock(= ) deadlock") Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- kernel/cgroup/cgroup-v1.c | 2 ++ 1 file changed, 2 insertions(+) --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c @@ -57,6 +57,7 @@ int cgroup_attach_task_all(struct task_s int retval =3D 0; =20 mutex_lock(&cgroup_mutex); + cpus_read_lock(); percpu_down_write(&cgroup_threadgroup_rwsem); for_each_root(root) { struct cgroup *from_cgrp; @@ -73,6 +74,7 @@ int cgroup_attach_task_all(struct task_s break; } percpu_up_write(&cgroup_threadgroup_rwsem); + cpus_read_unlock(); mutex_unlock(&cgroup_mutex); =20 return retval;