From: Richard Larocque <rlarocque@google.com>
To: tglx@linutronix.de, john.stultz@linaro.org
Cc: linux-kernel@vger.kernel.org, Richard Larocque <rlarocque@google.com>
Subject: [PATCH 2/3] alarmtimer: Do not signal SIGEV_NONE timers
Date: Tue, 9 Sep 2014 18:31:04 -0700 [thread overview]
Message-ID: <1410312665-25381-3-git-send-email-rlarocque@google.com> (raw)
In-Reply-To: <1410312665-25381-1-git-send-email-rlarocque@google.com>
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.
Signed-off-by: Richard Larocque <rlarocque@google.com>
---
kernel/time/alarmtimer.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
index cb31fd0..091d660 100644
--- a/kernel/time/alarmtimer.c
+++ b/kernel/time/alarmtimer.c
@@ -466,8 +466,10 @@ static enum alarmtimer_restart alarm_handle_timer(struct alarm *alarm,
{
struct k_itimer *ptr = container_of(alarm, struct k_itimer,
it.alarm.alarmtimer);
- if (posix_timer_event(ptr, 0) != 0)
- ptr->it_overrun++;
+ if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID) != SIGEV_NONE) {
+ if (posix_timer_event(ptr, 0) != 0)
+ ptr->it_overrun++;
+ }
/* Re-add periodic timers */
if (ptr->it.alarm.interval.tv64) {
--
2.1.0.rc2.206.gedb03e5
next prev parent reply other threads:[~2014-09-10 1:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-10 1:31 [PATCH 0/3] alarmtimer: Fix some non-standard alarm timer behavior Richard Larocque
2014-09-10 1:31 ` [PATCH 1/3] alarmtimer: Return relative times in timer_gettime Richard Larocque
2014-09-10 1:31 ` Richard Larocque [this message]
2014-09-10 1:31 ` [PATCH 3/3] alarmtimer: Lock k_itimer during timer callback Richard Larocque
2014-09-10 3:33 ` [PATCH 0/3] alarmtimer: Fix some non-standard alarm timer behavior John Stultz
2014-09-10 17:40 ` Richard Larocque
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1410312665-25381-3-git-send-email-rlarocque@google.com \
--to=rlarocque@google.com \
--cc=john.stultz@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome