[tip: core/rcu] srcu: Fix process_srcu()/srcu_batches_completed() datarace
From: tip-bot2 for Paul E. McKenney
Date: Tue Mar 24 2020 - 05:18:55 EST
The following commit has been merged into the core/rcu branch of tip:
Commit-ID: 39f91504a03a7a2abdb52205106942fa4a548d0d
Gitweb: https://git.kernel.org/tip/39f91504a03a7a2abdb52205106942fa4a548d0d
Author: Paul E. McKenney <paulmck@xxxxxxxxxx>
AuthorDate: Sun, 22 Dec 2019 19:39:35 -08:00
Committer: Paul E. McKenney <paulmck@xxxxxxxxxx>
CommitterDate: Thu, 20 Feb 2020 16:01:11 -08:00
srcu: Fix process_srcu()/srcu_batches_completed() datarace
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@xxxxxxxxxx>
---
kernel/rcu/srcutree.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 79848f7..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);
}
EXPORT_SYMBOL_GPL(srcu_batches_completed);