Skip to content

Commit 0e334db

Browse files
KAGA-KOKOIngo Molnar
authored andcommitted
posix-timers: Fix division by zero bug
The signal delivery path of posix-timers can try to rearm the timer even if the interval is zero. That's handled for the common case (hrtimer) but not for alarm timers. In that case the forwarding function raises a division by zero exception. The handling for hrtimer based posix timers is wrong because it marks the timer as active despite the fact that it is stopped. Move the check from common_hrtimer_rearm() to posixtimer_rearm() to cure both issues. Reported-by: syzbot+9d38bedac9cc77b8ad5e@syzkaller.appspotmail.com Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: sboyd@kernel.org Cc: stable@vger.kernel.org Cc: syzkaller-bugs@googlegroups.com Link: http://lkml.kernel.org/r/alpine.DEB.2.21.1812171328050.1880@nanos.tec.linutronix.de Signed-off-by: Ingo Molnar <mingo@kernel.org>
1 parent 7566ec3 commit 0e334db

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

kernel/time/posix-timers.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,6 @@ static void common_hrtimer_rearm(struct k_itimer *timr)
289289
{
290290
struct hrtimer *timer = &timr->it.real.timer;
291291

292-
if (!timr->it_interval)
293-
return;
294-
295292
timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(),
296293
timr->it_interval);
297294
hrtimer_restart(timer);
@@ -317,7 +314,7 @@ void posixtimer_rearm(struct kernel_siginfo *info)
317314
if (!timr)
318315
return;
319316

320-
if (timr->it_requeue_pending == info->si_sys_private) {
317+
if (timr->it_interval && timr->it_requeue_pending == info->si_sys_private) {
321318
timr->kclock->timer_rearm(timr);
322319

323320
timr->it_active = 1;

0 commit comments

Comments
 (0)