Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp411827lqb; Tue, 4 Jun 2024 15:37:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUCJWWSppvcxWN9QbCSJI4fjJCtY8FbvOvlX0qG2EE7n6MxUv+pFJ7wqTixn5aswzgswBhrpdF15si7zqbd5aIAy5Q6COQK78kUXivlOA== X-Google-Smtp-Source: AGHT+IFEqyCU2kZ12C/Fn5lI4k5KQbvMRax9AH75wA75hHdtTacSHVLZJwLA6gJI8SX38IqvKRjz X-Received: by 2002:a05:6a00:4b14:b0:6f8:e442:a28a with SMTP id d2e1a72fcca58-703e59e479bmr818683b3a.21.1717540635468; Tue, 04 Jun 2024 15:37:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717540635; cv=pass; d=google.com; s=arc-20160816; b=N3fFBIJIBvwgntGN2SROmRcDjc7m/HRmjzo6yJkjV3fOHAOlWaSSz/Cyengzb8GGZ4 8ueiGuQlsob7CkaowmVWMqzo/yJ11tJU5RTCeiBprtdZvItcwDT/Blc8Wj2+//A+UNej eay21pypHqFMUQKN3y2+0AAcXhhgScJEZR1Ml1JERA8EY0t1/WiYPi+Raq95/FOgvnUH bGd4yEXsr5ULlrFryOa61Ss25v9GKzUgvZZ4rWBC33ihjQrdGWbjmD+5FlPnyELAXIjC SPUXcbvMqof7BrTBeNJzK5mipDRymGdSWlNlL19CwJh6Q9FXRnItu2N8g+IzjzxcKnvw +nUg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=chb9X1EdNZO7eVwZukx05DsmvpaRvgAKv7ZsRMoWBM0=; fh=f8E1eMpO3U3yPJt6moXL1m3uGC8xSawVJE6XK5RxOoU=; b=WgIHdKd+aozBqRaQc4W0YBR7k9MNn3uXnGbnFXcreu3XQNJA0OvQXt3moEQKKdPQ8d VTCQYtfOXZpj0HfqE0w32e24j/HAJJYlOoLF0BoyAyVPwTato3qYIZBpoKgWOEeRZBbH IjBduKRyCTTNEJ7pmyFGoKjn3P5K2BC2Xl3MVg8+UdUDjIov2SzgHNMSJLqyG/unK2z4 71uFEOeNgvOG7o1awiuuADp5SzX+AsOppFP1BWvWJ4qsGB2tCaKjO/DaQNTAF0xH6uUF oa7YGbLcYz1rCkd0H9k5ws/l9cPRKz0Ix2gNdOF1viYSw0idDSRjYHc9yfplFPXpRdw7 8Ldw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fjtHMhPW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-702820e2051si2144226b3a.338.2024.06.04.15.37.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 15:37:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=fjtHMhPW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-201496-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201496-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1F294281641 for ; Tue, 4 Jun 2024 22:37:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6225C14D701; Tue, 4 Jun 2024 22:36:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fjtHMhPW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A3D614D43E; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; cv=none; b=AC4JcfLTyp11V2SXJJ2GvGC3Xjd7RmmfEgXmjRHuPP+gSwEPeUsjlIdZ1kzv/2ETzUCXPho6iya0DnQ4yoQSbWf6M030mVW108zQoWNCr8WRKeq/1wLqDUysXdJ0qpRIj9kTfFCmtf71uQ9w4mtsoSlj5QnAjL2fszXN/v7yMJg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540595; c=relaxed/simple; bh=A1B89F6f71BTaBD2c6ys6oWMLDn6LLn8Xrl2YURYyWA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FOGXLgkSoaZnhF5wIdx+gRlh0rgcTAVSfD+Y9FGeZwd8Bzhxc5UJbIYGzTi3rVCH4B9+pRVWC4BLVCpeZgAs8sPmm/kSRfuBxSdaKEHGUUhI8de0JgiZLUrXX8ZdAXeX6UQXgz8StSuqsiuEuxhPAOHYgivRBf31HIK0OTcRGzE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fjtHMhPW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B587C2BBFC; Tue, 4 Jun 2024 22:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717540595; bh=A1B89F6f71BTaBD2c6ys6oWMLDn6LLn8Xrl2YURYyWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fjtHMhPWw2cR4PKJ4a0oFaDUSfzScELdWeoI4yGMOj6zZsTY5rpLw4sHKmci/EDZ/ YMAlVPmKdbylzk/bLssle5qYVVtiaQkLDmcX2mboeOxYQznzlE2GEEppbSeuB4jT1O JLyT1qg1Vv2qWQYSvcsbKAixmlFLZNvEqoWB/IMppEDrOPTKUyfPBfb1WuPW3GcGaY SBiTP6nNBzvnkZ030aBFPgn9Y7qt2EHZUtKnEpQvUGqUpi8FsJrLCD5+lQyratdNq7 eIXom5hhimQr3PhG3pVl/QNUW0+yVjH4dbjqtbZ+OOv3FkJlq5c6ivT4VuQQEVzods XPbom4jpExVMg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id DF4C3CE3F0F; Tue, 4 Jun 2024 15:36:34 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@meta.com, rostedt@goodmis.org, "Paul E. McKenney" , Marco Elver , Andrey Konovalov , kasan-dev@googlegroups.com Subject: [PATCH rcu 2/4] rcutorture: Fix rcu_torture_fwd_cb_cr() data race Date: Tue, 4 Jun 2024 15:36:31 -0700 Message-Id: <20240604223633.2371664-2-paulmck@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On powerpc systems, spinlock acquisition does not order prior stores against later loads. This means that this statement: rfcp->rfc_next = NULL; Can be reordered to follow this statement: WRITE_ONCE(*rfcpp, rfcp); Which is then a data race with rcu_torture_fwd_prog_cr(), specifically, this statement: rfcpn = READ_ONCE(rfcp->rfc_next) KCSAN located this data race, which represents a real failure on powerpc. Signed-off-by: Paul E. McKenney Cc: Marco Elver Cc: Andrey Konovalov Cc: --- kernel/rcu/rcutorture.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 44cc455e1b615..cafe047d046e8 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2630,7 +2630,7 @@ static void rcu_torture_fwd_cb_cr(struct rcu_head *rhp) spin_lock_irqsave(&rfp->rcu_fwd_lock, flags); rfcpp = rfp->rcu_fwd_cb_tail; rfp->rcu_fwd_cb_tail = &rfcp->rfc_next; - WRITE_ONCE(*rfcpp, rfcp); + smp_store_release(rfcpp, rfcp); WRITE_ONCE(rfp->n_launders_cb, rfp->n_launders_cb + 1); i = ((jiffies - rfp->rcu_fwd_startat) / (HZ / FWD_CBS_HIST_DIV)); if (i >= ARRAY_SIZE(rfp->n_launders_hist)) -- 2.40.1