Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp760132pxb; Tue, 5 Apr 2022 22:07:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRxTr5t7Hvw1Xx+wYx4wf0AjLVkg4/uEVj+NhFcGeJoZKOn5AIkyrWX40gMi/+RnuZCMU5 X-Received: by 2002:a63:cf4d:0:b0:399:40fc:addf with SMTP id b13-20020a63cf4d000000b0039940fcaddfmr5668690pgj.416.1649221654250; Tue, 05 Apr 2022 22:07:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649221654; cv=none; d=google.com; s=arc-20160816; b=s5FQL79SJuUvS6aZVEPN+pJQHOKfU4/hyqD6uLBd8UBb9dQsIm0e+mAltWMd74daVA 0eaCvsqDYWTmqg0Lud+enL4mcZvOLcYlgF8GiHwKhS0nwp3SiS6cIfE0NOHGNSbsQDpp KN4R8JmRTBX032y8xM3D9qV/ZprSWWKfV/rvXrJxtGxwkjlpblxou9kY4TIExtupQVSz W5zAmuF8lwSCdCqJT7ZU82PZ812uw9Ej5O5NVEl4+LCFM5SxMKjAPHDTp1P43XehX3XF a7OVuLwvwDwRj+6fP7n8mCCglruYZunTArG0IxewCiN73v54MJ4fZ3dXCrYdIFj2/AHc j/5w== 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=WyPe26quBHS4SnXCbm138yC1A5UQFwHSzRV82Q2T7WQ=; b=w8gz+t5pi/diLb/+7GccI4EaU3c3mURLOz9coAc9H2KaY/aIR+th97RsSx0W5QMi47 cHHa4gjK8rIMI5Fa6Jp5KkD04rPKbk42+fihSjPvL4iPSbmFRnEv6UB/AJuh5lQg6Uhk KxlZIezcWlgv1p+1sqi1M/0Y4mcXPfBgmmqqigvfebO1LI/CEwYucSpwLb6dpEnK4ADR bQbQa14RNtxsMNBPX88HpfTmP12iIJySttmHhzRwwvZQ2v92c1IvHDQz+DZO68bNY21c rYg5BICk4PGU/0lsgogsujGbBFpfXJac4HLemLLpccPLs3HWb9Rx98+YIVi+mr37rce1 fIPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f0G9tQll; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b16-20020a056a000a9000b004fade889fd0si15426934pfl.15.2022.04.05.22.07.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 22:07:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=f0G9tQll; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 446CA3E4C34; Tue, 5 Apr 2022 20:31:09 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346875AbiDEJpk (ORCPT + 99 others); Tue, 5 Apr 2022 05:45:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235568AbiDEIVa (ORCPT ); Tue, 5 Apr 2022 04:21:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB2FE2196; Tue, 5 Apr 2022 01:19:17 -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 2CB4360B12; Tue, 5 Apr 2022 08:19:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37F55C385A0; Tue, 5 Apr 2022 08:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649146756; bh=fUO8fVrX1Jo52Tl8cdXg4tG8zouKK4Q2Jo6qUwezPwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f0G9tQllYSKIWjzEA5PgcYmqBdMdRs+VYP1uBp8qXa7DW521PLreQgWe5OH6nxFfV hyFiddRPlBwTFjkPdKKHh34paHpXcZKjSg4Gxspcl9kyfBov7k8ByOLN8n7/pzGhVV b2zSsDX+z/2Hwb4eMnhzO75orSdkNP5oNqgp+mb4= 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.17 0840/1126] rcu: Mark writes to the rcu_segcblist structures ->flags field Date: Tue, 5 Apr 2022 09:26:27 +0200 Message-Id: <20220405070432.210797778@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 e373fbe44da5..431cee212467 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