Skip to content

Commit cceb634

Browse files
committed
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
2 parents 713f0f3 + bb7262b commit cceb634

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

kernel/time/timer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,10 @@ static inline void timer_base_unlock_expiry(struct timer_base *base)
12651265
static void timer_sync_wait_running(struct timer_base *base)
12661266
{
12671267
if (atomic_read(&base->timer_waiters)) {
1268+
raw_spin_unlock_irq(&base->lock);
12681269
spin_unlock(&base->expiry_lock);
12691270
spin_lock(&base->expiry_lock);
1271+
raw_spin_lock_irq(&base->lock);
12701272
}
12711273
}
12721274

@@ -1457,14 +1459,14 @@ static void expire_timers(struct timer_base *base, struct hlist_head *head)
14571459
if (timer->flags & TIMER_IRQSAFE) {
14581460
raw_spin_unlock(&base->lock);
14591461
call_timer_fn(timer, fn, baseclk);
1460-
base->running_timer = NULL;
14611462
raw_spin_lock(&base->lock);
1463+
base->running_timer = NULL;
14621464
} else {
14631465
raw_spin_unlock_irq(&base->lock);
14641466
call_timer_fn(timer, fn, baseclk);
1467+
raw_spin_lock_irq(&base->lock);
14651468
base->running_timer = NULL;
14661469
timer_sync_wait_running(base);
1467-
raw_spin_lock_irq(&base->lock);
14681470
}
14691471
}
14701472
}

0 commit comments

Comments
 (0)