@@ -53,6 +53,14 @@ enum siginfo_layout {
enum siginfo_layout siginfo_layout(unsigned sig, int si_code);
+/* Test if 'sig' is a realtime signal. Use this instead of testing
+ * SIGRTMIN/SIGRTMAX directly.
+ */
+static inline int realtime_signal(unsigned long sig)
+{
+ return (sig >= SIGRTMIN) && (sig <= SIGRTMAX);
+}
+
/*
* Define some primitives to manipulate sigset_t.
*/
@@ -1065,7 +1065,7 @@ static void complete_signal(int sig, struct task_struct *p, enum pid_type type)
static inline bool legacy_queue(struct sigpending *signals, int sig)
{
- return (sig < SIGRTMIN) && sigismember(&signals->signal, sig);
+ return !realtime_signal(sig) && sigismember(&signals->signal, sig);
}
static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struct *t,
@@ -1108,7 +1108,7 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struc
* make sure at least one signal gets delivered and don't
* pass on the info struct.
*/
- if (sig < SIGRTMIN)
+ if (!realtime_signal(sig))
override_rlimit = (is_si_special(info) || info->si_code >= 0);
else
override_rlimit = 0;
@@ -1144,7 +1144,7 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struc
break;
}
} else if (!is_si_special(info) &&
- sig >= SIGRTMIN && info->si_code != SI_USER) {
+ realtime_signal(sig) && info->si_code != SI_USER) {
/*
* Queue overflow, abort. We may abort if the
* signal was rt and sent by user using something
@@ -442,7 +442,8 @@ static struct pid *good_sigevent(sigevent_t * event)
fallthrough;
case SIGEV_SIGNAL:
case SIGEV_THREAD:
- if (event->sigev_signo <= 0 || event->sigev_signo > SIGRTMAX)
+ /* Signal 0 is a valid signal, just not here. */
+ if (!valid_signal(event->sigev_signo) || event->sigev_signo == 0)
return NULL;
fallthrough;
case SIGEV_NONE:
@@ -130,9 +130,9 @@ int aa_may_ptrace(struct aa_label *tracer, struct aa_label *tracee,
static inline int map_signal_num(int sig)
{
- if (sig > SIGRTMAX)
+ if (!valid_signal(sig))
return SIGUNKNOWN;
- else if (sig >= SIGRTMIN)
+ else if (realtime_signal(sig))
return sig - SIGRTMIN + SIGRT_BASE;
else if (sig < MAXMAPPED_SIG)
return sig_map[sig];
Rather than testing against SIGRTMIN/SIGRTMAX directly, use this helper to determine if a signal is a real-time signal. Signed-off-by: Walt Drummond <walt@drummond.us> --- include/linux/signal.h | 8 ++++++++ kernel/signal.c | 6 +++--- kernel/time/posix-timers.c | 3 ++- security/apparmor/ipc.c | 4 ++-- 4 files changed, 15 insertions(+), 6 deletions(-)