Blob Blame History Raw
From: "Paul E. McKenney" <paulmck@kernel.org>
Date: Sun, 22 Dec 2019 19:55:50 -0800
Subject: rcu: Fix exp_funnel_lock()/rcu_exp_wait_wake() datarace
Patch-mainline: v5.7-rc1
Git-commit: 24bb9eccf7ff335c16c2970ac7cd5c32a92821a6
References: bsc#1171828

The rcu_node structure's ->exp_seq_rq field is accessed locklessly, so
updates must use WRITE_ONCE().  This commit therefore adds the needed
WRITE_ONCE() invocation where it was missed.

This data race was reported by KCSAN.  Not appropriate for backporting
due to failure being unlikely.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Acked-by: Daniel Wagner <dwagner@suse.de>
---
 kernel/rcu/tree_exp.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/kernel/rcu/tree_exp.h
+++ b/kernel/rcu/tree_exp.h
@@ -554,7 +554,7 @@ static void rcu_exp_wait_wake(unsigned l
 			spin_lock(&rnp->exp_lock);
 			/* Recheck, avoid hang in case someone just arrived. */
 			if (ULONG_CMP_LT(rnp->exp_seq_rq, s))
-				rnp->exp_seq_rq = s;
+				WRITE_ONCE(rnp->exp_seq_rq, s);
 			spin_unlock(&rnp->exp_lock);
 		}
 		smp_mb(); /* All above changes before wakeup. */