Skip to content

Commit f11d225

Browse files
rlarocque2gregkh
authored andcommitted
alarmtimer: Do not signal SIGEV_NONE timers
commit 265b81d upstream. Avoids sending a signal to alarm timers created with sigev_notify set to SIGEV_NONE by checking for that special case in the timeout callback. The regular posix timers avoid sending signals to SIGEV_NONE timers by not scheduling any callbacks for them in the first place. Although it would be possible to do something similar for alarm timers, it's simpler to handle this as a special case in the timeout. Prior to this patch, the alarm timer would ignore the sigev_notify value and try to deliver signals to the process anyway. Even worse, the sanity check for the value of sigev_signo is skipped when SIGEV_NONE was specified, so the signal number could be bogus. If sigev_signo was an unitialized value (as it often would be if SIGEV_NONE is used), then it's hard to predict which signal will be sent. Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@kernel.org> Cc: Richard Cochran <richardcochran@gmail.com> Cc: Prarit Bhargava <prarit@redhat.com> Cc: Sharvil Nanavati <sharvil@google.com> Signed-off-by: Richard Larocque <rlarocque@google.com> Signed-off-by: John Stultz <john.stultz@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent bffe424 commit f11d225

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎kernel/time/alarmtimer.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -466,8 +466,10 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
466466
{
467467
struct k_itimer *ptr = container_of(alarm, struct k_itimer,
468468
it.alarm.alarmtimer);
469-
if (posix_timer_event(ptr, 0) != 0)
470-
ptr->it_overrun++;
469+
if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
470+
if (posix_timer_event(ptr, 0) != 0)
471+
ptr->it_overrun++;
472+
}
471473

472474
/* Re-add periodic timers */
473475
if (ptr->it.alarm.interval.tv64) {

0 commit comments

Comments
 (0)