From mboxrd@z Thu Jan 1 00:00:00 1970 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 B2E7FC433FE for ; Tue, 18 Oct 2022 00:15:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230183AbiJRAPq (ORCPT ); Mon, 17 Oct 2022 20:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231748AbiJRAOP (ORCPT ); Mon, 17 Oct 2022 20:14:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3D2888DF8; Mon, 17 Oct 2022 17:10:50 -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 ams.source.kernel.org (Postfix) with ESMTPS id BFA04B81C04; Tue, 18 Oct 2022 00:10:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8934FC43470; Tue, 18 Oct 2022 00:10:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666051839; bh=pi8pLsYW4g0+QIgNtoUdgUCpe0BC5kGnIcEdILtWFCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dc92d1ac9j9u7r+OmjaAvRO46WjcIArVGC84qt4VOXfO6HWg3CTF1ikMWxVL8QJG1 97anq76AAQ7bPwGvxgsSBJ6w1bJFt4rJbRBjMz8E5nCLhs1QYchyxwTLQavXF9pe0b +0mxFza//hrj4n65mp5tG/1JsARRkpwhGUeiQarAybKYCR3Vzrry101FmsjmENHHax pwJBknN5edV7PyR9gCaTqelkgelKENujG1uZEZyTZhb+TKDINjqwAGy1lKiOxSgW1l +e7dS0AyajPkLVas/en7u1p3YOBCTANwyQwrQpg2sDUQMPoZfmzl05PCidlgALOBhL luDUfLkU7Hl4A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Tejun Heo , Abhishek Shah , Gabriel Ryan , Christian Brauner , Sasha Levin , lizefan.x@bytedance.com, hannes@cmpxchg.org, cgroups@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 05/16] cgroup: Remove data-race around cgrp_dfl_visible Date: Mon, 17 Oct 2022 20:10:18 -0400 Message-Id: <20221018001029.2731620-5-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018001029.2731620-1-sashal@kernel.org> References: <20221018001029.2731620-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tejun Heo [ Upstream commit dc79ec1b232ad2c165d381d3dd2626df4ef9b5a4 ] There's a seemingly harmless data-race around cgrp_dfl_visible detected by kernel concurrency sanitizer. Let's remove it by throwing WRITE/READ_ONCE at it. Signed-off-by: Tejun Heo Reported-by: Abhishek Shah Cc: Gabriel Ryan Reviewed-by: Christian Brauner (Microsoft) Link: https://lore.kernel.org/netdev/20220819072256.fn7ctciefy4fc4cu@wittgenstein/ Signed-off-by: Sasha Levin --- kernel/cgroup/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 684c16849eff..5178593ee1f1 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2110,7 +2110,7 @@ static int cgroup_get_tree(struct fs_context *fc) struct cgroup_fs_context *ctx = cgroup_fc2context(fc); int ret; - cgrp_dfl_visible = true; + WRITE_ONCE(cgrp_dfl_visible, true); cgroup_get_live(&cgrp_dfl_root.cgrp); ctx->root = &cgrp_dfl_root; @@ -5946,7 +5946,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, struct cgroup *cgrp; int ssid, count = 0; - if (root == &cgrp_dfl_root && !cgrp_dfl_visible) + if (root == &cgrp_dfl_root && !READ_ONCE(cgrp_dfl_visible)) continue; seq_printf(m, "%d:", root->hierarchy_id); -- 2.35.1 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sasha Levin Subject: [PATCH AUTOSEL 5.10 05/16] cgroup: Remove data-race around cgrp_dfl_visible Date: Mon, 17 Oct 2022 20:10:18 -0400 Message-ID: <20221018001029.2731620-5-sashal@kernel.org> References: <20221018001029.2731620-1-sashal@kernel.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666051839; bh=pi8pLsYW4g0+QIgNtoUdgUCpe0BC5kGnIcEdILtWFCU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dc92d1ac9j9u7r+OmjaAvRO46WjcIArVGC84qt4VOXfO6HWg3CTF1ikMWxVL8QJG1 97anq76AAQ7bPwGvxgsSBJ6w1bJFt4rJbRBjMz8E5nCLhs1QYchyxwTLQavXF9pe0b +0mxFza//hrj4n65mp5tG/1JsARRkpwhGUeiQarAybKYCR3Vzrry101FmsjmENHHax pwJBknN5edV7PyR9gCaTqelkgelKENujG1uZEZyTZhb+TKDINjqwAGy1lKiOxSgW1l +e7dS0AyajPkLVas/en7u1p3YOBCTANwyQwrQpg2sDUQMPoZfmzl05PCidlgALOBhL luDUfLkU7Hl4A== In-Reply-To: <20221018001029.2731620-1-sashal-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org> List-ID: Content-Type: text/plain; charset="us-ascii" To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Tejun Heo , Abhishek Shah , Gabriel Ryan , Christian Brauner , Sasha Levin , lizefan.x-EC8Uxl6Npydl57MIdRCFDg@public.gmane.org, hannes-druUgvl0LCNAfugRpC6u6w@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org From: Tejun Heo [ Upstream commit dc79ec1b232ad2c165d381d3dd2626df4ef9b5a4 ] There's a seemingly harmless data-race around cgrp_dfl_visible detected by kernel concurrency sanitizer. Let's remove it by throwing WRITE/READ_ONCE at it. Signed-off-by: Tejun Heo Reported-by: Abhishek Shah Cc: Gabriel Ryan Reviewed-by: Christian Brauner (Microsoft) Link: https://lore.kernel.org/netdev/20220819072256.fn7ctciefy4fc4cu@wittgenstein/ Signed-off-by: Sasha Levin --- kernel/cgroup/cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 684c16849eff..5178593ee1f1 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -2110,7 +2110,7 @@ static int cgroup_get_tree(struct fs_context *fc) struct cgroup_fs_context *ctx = cgroup_fc2context(fc); int ret; - cgrp_dfl_visible = true; + WRITE_ONCE(cgrp_dfl_visible, true); cgroup_get_live(&cgrp_dfl_root.cgrp); ctx->root = &cgrp_dfl_root; @@ -5946,7 +5946,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, struct cgroup *cgrp; int ssid, count = 0; - if (root == &cgrp_dfl_root && !cgrp_dfl_visible) + if (root == &cgrp_dfl_root && !READ_ONCE(cgrp_dfl_visible)) continue; seq_printf(m, "%d:", root->hierarchy_id); -- 2.35.1