Skip to content

Commit

Permalink
timers: Add missing READ_ONCE() in __run_timer_base()
Browse files Browse the repository at this point in the history
__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: 79f8b28 ("timers: Annotate possible non critical data race of next_expiry")
Reported-by: kernel test robot <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Frederic Weisbecker <[email protected]>
Link: https://lore.kernel.org/all/87a5emyqk0.ffs@tglx
Closes: https://lore.kernel.org/oe-lkp/[email protected]
  • Loading branch information
KAGA-KOKO committed Oct 31, 2024
1 parent bf9a001 commit 1d4199c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion kernel/time/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1d4199c

Please sign in to comment.