]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
rcu: Mark writes to the rcu_segcblist structure's ->flags field
authorPaul E. McKenney <paulmck@kernel.org>
Tue, 4 Jan 2022 18:34:34 +0000 (10:34 -0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 12:39:41 +0000 (14:39 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969110
[ Upstream commit c09929031018913b5783872a8b8cdddef4a543c7 ]

KCSAN reports data races between the rcu_segcblist_clear_flags() and
rcu_segcblist_set_flags() functions, though misreporting the latter
as a call to rcu_segcblist_is_enabled() from call_rcu().  This commit
converts the updates of this field to WRITE_ONCE(), relying on the
resulting unmarked reads to continue to detect buggy concurrent writes
to this field.

Reported-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Frederic Weisbecker <frederic@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit e34806c6c29d7066ac8de17db6c3dc542a629f1b)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
kernel/rcu/rcu_segcblist.h

index 9a19328ff251440d9e19e9211c78cfe0285f9de1..5d405943823ec6e8f87c40ea9bf6caa795b0c2fb 100644 (file)
@@ -56,13 +56,13 @@ static inline long rcu_segcblist_n_cbs(struct rcu_segcblist *rsclp)
 static inline void rcu_segcblist_set_flags(struct rcu_segcblist *rsclp,
                                           int flags)
 {
-       rsclp->flags |= flags;
+       WRITE_ONCE(rsclp->flags, rsclp->flags | flags);
 }
 
 static inline void rcu_segcblist_clear_flags(struct rcu_segcblist *rsclp,
                                             int flags)
 {
-       rsclp->flags &= ~flags;
+       WRITE_ONCE(rsclp->flags, rsclp->flags & ~flags);
 }
 
 static inline bool rcu_segcblist_test_flags(struct rcu_segcblist *rsclp,