Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp661065pxb; Tue, 5 Apr 2022 17:44:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNcSWy++DisOWHbj7v9H9dnOIVPAMb+w3yiW6wz7miDvCqt9WI0kJJxtlUNTPfn7MpjGaX X-Received: by 2002:a63:694a:0:b0:380:103:64ee with SMTP id e71-20020a63694a000000b00380010364eemr5051454pgc.213.1649205876584; Tue, 05 Apr 2022 17:44:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649205876; cv=none; d=google.com; s=arc-20160816; b=KtADX6QQ7J4ZAD89COall1Vig6Y9qYC61cjptapHR//uWg9VJr/WpEie9zXv2nhztm rX/gXXl+3uwt5Z/mEZFZGQqc2KiS9iKo1NyMB/L1arNzGQztJRsqDXMYtFo1S0NdVCEy QK7YHE0K5i5jpuXOQgRlJugHkqSLbY+m2uQoCndeLPwJmK0y/ScHXDEz41PnaLdJ7uSD RNioFVNLQFTYeLy4LxnletM4R0PZx4h6Hl/MKV8mYRdKVETbVs9upJufj92fZFzDzCU3 pYTu/y9GitG4hktu++pkH/+yvsfUh5vHAPI6HEitpYCSApN9MMgxW4Uk05S5cI8tnZPI lzTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4G90kGNoCZE8TGShdR44ViuEUSqodLorp1eQ9Ue52Hs=; b=ULPay6uoeMLGxrpnW3bCtEiINlsTVozCOG1N65wdxL7jxDLTMpT0wJZvknTHdng107 U/fqcS4OgfdlKCURP1Xf1yDnje2/ePpnTsiBihVzDBFTLDf90RyDj50k7K0umSDh1w+Y OXb5XvdL5AyA1BW1UvI0FntZpfoCNR588Kk+Vdu7aQUWu4eE0QyCnkSBZNuC+nmKBHyQ 093Ho1tu63iDln7JMuVQvvkGhSuGL0rQvCA9/HGtIX4ynHr0vVT2LSXeBqL0/D7p1pmP kWc1h/KR0inofN8iK3eZ1rTPazVh72LCnOgTzvP7AD+IoqfaEbWM/lGSdwmhBAPgDeTb WzFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2gTgpYkS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w8-20020a056a0014c800b004fa3a8e0011si15204205pfu.200.2022.04.05.17.44.22; Tue, 05 Apr 2022 17:44:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2gTgpYkS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1390393AbiDENiZ (ORCPT + 99 others); Tue, 5 Apr 2022 09:38:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344351AbiDEJTe (ORCPT ); Tue, 5 Apr 2022 05:19:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 956AA2A1; Tue, 5 Apr 2022 02:07:44 -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 E9466614E4; Tue, 5 Apr 2022 09:07:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 029A9C385A1; Tue, 5 Apr 2022 09:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649149663; bh=aHqT1HFZ5CvSbqfy/C/L/NOwod6STlMUwvXPGsSKQro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2gTgpYkSEGPPLWsbv8mYgCYWIKpy1on72Zaavmc9yslEegKPvzwODsO//xZQDOwyj T3iSPy6dfQbvpiW3esawNarHAb6iu2UzFcEknO00Ccy+mz0XiDVjLdj+AsASMdLIeA xJq8Z2JuRWOClJNxYZDjfeXt7tseXiJMBTW5GUc8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhouyi Zhou , "Paul E. McKenney" , Frederic Weisbecker , Sasha Levin Subject: [PATCH 5.16 0757/1017] rcu: Mark writes to the rcu_segcblist structures ->flags field Date: Tue, 5 Apr 2022 09:27:50 +0200 Message-Id: <20220405070416.729358398@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Paul E. McKenney [ Upstream commit c09929031018913b5783872a8b8cdddef4a543c7 ] KCSAN reports data races between the rcu_segcblist_clear_flags() and rcu_segcblist_set_flags() functions, though misreporting the latter as a call to rcu_segcblist_is_enabled() from call_rcu(). This commit converts the updates of this field to WRITE_ONCE(), relying on the resulting unmarked reads to continue to detect buggy concurrent writes to this field. Reported-by: Zhouyi Zhou Signed-off-by: Paul E. McKenney Cc: Frederic Weisbecker Signed-off-by: Sasha Levin --- kernel/rcu/rcu_segcblist.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/rcu/rcu_segcblist.h b/kernel/rcu/rcu_segcblist.h index 9a19328ff251..5d405943823e 100644 --- a/kernel/rcu/rcu_segcblist.h +++ b/kernel/rcu/rcu_segcblist.h @@ -56,13 +56,13 @@ static inline long rcu_segcblist_n_cbs(struct rcu_segcblist *rsclp) static inline void rcu_segcblist_set_flags(struct rcu_segcblist *rsclp, int flags) { - rsclp->flags |= flags; + WRITE_ONCE(rsclp->flags, rsclp->flags | flags); } static inline void rcu_segcblist_clear_flags(struct rcu_segcblist *rsclp, int flags) { - rsclp->flags &= ~flags; + WRITE_ONCE(rsclp->flags, rsclp->flags & ~flags); } static inline bool rcu_segcblist_test_flags(struct rcu_segcblist *rsclp, -- 2.34.1