From mboxrd@z Thu Jan 1 00:00:00 1970 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 8253A19DFA6; Thu, 15 Aug 2024 13:59:54 +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=1723730394; cv=none; b=lHnLYxjV0hIUxQFp4FUroQjG5C2zfiDWp5CaQMUvBC46xADQHP5/4ubE884JsqAEjFVm93brliEVPY6yoKHoU6OjdRaoHi8wKOQceZF9j+ptVdMiGkTPXKAuToiNSVta1OSiqlteJJROn44kv7dT9M889Df289qbj5adDIc7ncI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723730394; c=relaxed/simple; bh=t32yhA0i59JFLL8btd3UEYndgZallchqcaVPjUGY6LI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=owOEuN5snNLK6DgTIGrcpX5AWPWedu5g4XoGzmieNzEVpcEbn1kJBE+ocvWPecXKn2iO8MuLvjulXJLc3lsEsQ1RTaWuT+3mHUMF7NCX5MoUOLy8jscT8awlfckitPiEp7UI7TqSALid7iLl89q///8WZjYndWuj843aW9G32eA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=oj2VQ6xk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="oj2VQ6xk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEF3CC32786; Thu, 15 Aug 2024 13:59:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1723730394; bh=t32yhA0i59JFLL8btd3UEYndgZallchqcaVPjUGY6LI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oj2VQ6xkoY1zTJ4k5+woqdRUuQ65fGDjtlFBju28BuGlAVBYpHG6Vi4P/TPvOdVOe OQfFIAqfSgFiYTO+6DM/JCFz9UZGZQqzv/zWjduWq2Knwl1pcZdp7hJlqmwiwTznkI ImzpjyRDV6jAAVXJovxfBLqsyaZkk1sIIiy+rF/4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Paul E. McKenney" , Marco Elver , Andrey Konovalov , kasan-dev@googlegroups.com, Sasha Levin Subject: [PATCH 5.15 367/484] rcutorture: Fix rcu_torture_fwd_cb_cr() data race Date: Thu, 15 Aug 2024 15:23:45 +0200 Message-ID: <20240815131955.611546451@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240815131941.255804951@linuxfoundation.org> References: <20240815131941.255804951@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Paul E. McKenney [ Upstream commit 6040072f4774a575fa67b912efe7722874be337b ] 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 Acked-by: Marco Elver Cc: Andrey Konovalov Cc: Signed-off-by: Sasha Levin --- 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 9d8d1f233d7bd..a3bab6af4028f 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c @@ -2186,7 +2186,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.43.0