Merge tag 'timers-urgent-2021-08-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull timer fix from Thomas Gleixner:
"A single timer fix:

- Prevent a memory ordering issue in the timer expiry code which
makes it possible to observe falsely that the callback has been
executed already while that's not the case, which violates the
guarantee of del_timer_sync()"

* tag 'timers-urgent-2021-08-08' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
timers: Move clearing of base::timer_running under base:: Lock

Changed files
+4 -2
kernel
time
+4 -2
kernel/time/timer.c
··· 1265 1265 static void timer_sync_wait_running(struct timer_base *base) 1266 1266 { 1267 1267 if (atomic_read(&base->timer_waiters)) { 1268 + raw_spin_unlock_irq(&base->lock); 1268 1269 spin_unlock(&base->expiry_lock); 1269 1270 spin_lock(&base->expiry_lock); 1271 + raw_spin_lock_irq(&base->lock); 1270 1272 } 1271 1273 } 1272 1274 ··· 1459 1457 if (timer->flags & TIMER_IRQSAFE) { 1460 1458 raw_spin_unlock(&base->lock); 1461 1459 call_timer_fn(timer, fn, baseclk); 1462 - base->running_timer = NULL; 1463 1460 raw_spin_lock(&base->lock); 1461 + base->running_timer = NULL; 1464 1462 } else { 1465 1463 raw_spin_unlock_irq(&base->lock); 1466 1464 call_timer_fn(timer, fn, baseclk); 1465 + raw_spin_lock_irq(&base->lock); 1467 1466 base->running_timer = NULL; 1468 1467 timer_sync_wait_running(base); 1469 - raw_spin_lock_irq(&base->lock); 1470 1468 } 1471 1469 } 1472 1470 }