OSDN Git Service

rcu: Fix exp_funnel_lock()/rcu_exp_wait_wake() datarace
authorPaul E. McKenney <paulmck@kernel.org>
Mon, 23 Dec 2019 03:55:50 +0000 (19:55 -0800)
committerPaul E. McKenney <paulmck@kernel.org>
Thu, 20 Feb 2020 23:58:21 +0000 (15:58 -0800)
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>
kernel/rcu/tree_exp.h

index dcbd757..d7e0484 100644 (file)
@@ -589,7 +589,7 @@ static void rcu_exp_wait_wake(unsigned long s)
                        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. */