Skip to content

Commit

Permalink
posix-timers: Fix division by zero bug
Browse files Browse the repository at this point in the history
commit 0e334db upstream.

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: [email protected]
Signed-off-by: Thomas Gleixner <[email protected]>
Cc: John Stultz <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
KAGA-KOKO authored and gregkh committed Dec 29, 2018
1 parent 23572a6 commit 2f8f9e2
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions kernel/time/posix-timers.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ static void common_hrtimer_rearm(struct k_itimer *timr)
{
struct hrtimer *timer = &timr->it.real.timer;

if (!timr->it_interval)
return;

timr->it_overrun += hrtimer_forward(timer, timer->base->get_time(),
timr->it_interval);
hrtimer_restart(timer);
Expand All @@ -326,7 +323,7 @@ void posixtimer_rearm(struct siginfo *info)
if (!timr)
return;

if (timr->it_requeue_pending == info->si_sys_private) {
if (timr->it_interval && timr->it_requeue_pending == info->si_sys_private) {
timr->kclock->timer_rearm(timr);

timr->it_active = 1;
Expand Down

0 comments on commit 2f8f9e2

Please sign in to comment.