[tip/core/rcu,3/4] srcu: Fix process_srcu()/srcu_batches_completed() datarace
diff mbox series

Message ID 20200215002932.15976-3-paulmck@kernel.org
State In Next
Commit 4d1574431c0ad8ed5a95166c19488ecfb813f8f3
Headers show
  • SRCU updates for v5.7
Related show

Commit Message

Paul E. McKenney Feb. 15, 2020, 12:29 a.m. UTC
From: "Paul E. McKenney" <paulmck@kernel.org>

The srcu_struct structure's ->srcu_idx field is accessed locklessly,
so reads must use READ_ONCE().  This commit therefore adds the needed
READ_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>
 kernel/rcu/srcutree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff mbox series

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 79848f7d..119a373 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -1079,7 +1079,7 @@  EXPORT_SYMBOL_GPL(srcu_barrier);
 unsigned long srcu_batches_completed(struct srcu_struct *ssp)
-	return ssp->srcu_idx;
+	return READ_ONCE(ssp->srcu_idx);