]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
timers: Add missing READ_ONCE() in __run_timer_base()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 30 Oct 2024 07:53:51 +0000 (08:53 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 31 Oct 2024 10:45:01 +0000 (11:45 +0100)
__run_timer_base() checks base::next_expiry without holding
base::lock. That can race with a remote CPU updating next_expiry under the
lock. This is an intentional and harmless data race, but lacks a
READ_ONCE(), so KCSAN complains about this.

Add the missing READ_ONCE(). All other places are covered already.

Fixes: 79f8b28e85f8 ("timers: Annotate possible non critical data race of next_expiry")
Reported-by: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/all/87a5emyqk0.ffs@tglx
Closes: https://lore.kernel.org/oe-lkp/202410301205.ef8e9743-lkp@intel.com
kernel/time/timer.c

index 02355b275bab258c7e2b88faf923855dd133a30f..a283e524835dfbb1b17214af6f45e65f946ec72d 100644 (file)
@@ -2421,7 +2421,8 @@ static inline void __run_timers(struct timer_base *base)
 
 static void __run_timer_base(struct timer_base *base)
 {
-       if (time_before(jiffies, base->next_expiry))
+       /* Can race against a remote CPU updating next_expiry under the lock */
+       if (time_before(jiffies, READ_ONCE(base->next_expiry)))
                return;
 
        timer_base_lock_expiry(base);