summaryrefslogtreecommitdiffstats
path: root/kernel/rcu
diff options
context:
space:
mode:
authorPaul E. McKenney <paulmck@kernel.org>2019-12-22 19:39:35 -0800
committerPaul E. McKenney <paulmck@kernel.org>2020-02-20 16:01:11 -0800
commit39f91504a03a7a2abdb52205106942fa4a548d0d (patch)
tree21148b0b3bd1e4c676a50e9414e5a919fd85350c /kernel/rcu
parent8c9e0cb32315835825ea1ad725a858a2d2ce4a8e (diff)
downloadlinux-39f91504a03a7a2abdb52205106942fa4a548d0d.tar.bz2
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@kernel.org>
Diffstat (limited to 'kernel/rcu')
-rw-r--r--kernel/rcu/srcutree.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 79848f7d575d..119a37319e67 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);