From: George Anzinger <george@mvista.com>
To: Oleg Nesterov <oleg@tv-sign.ru>
Cc: paulmck@us.ibm.com, Roland McGrath <roland@redhat.com>,
akpm@osdl.org, linux-kernel@vger.kernel.org, dipankar@in.ibm.com,
mingo@elte.hu, suzannew@cs.pdx.edu
Subject: [PATCH] sigaction should clear all signals on SIG_IGN, not just < 32
Date: Wed, 16 Nov 2005 15:26:21 -0800 [thread overview]
Message-ID: <437BC01D.60302@mvista.com> (raw)
In-Reply-To: <436E1401.920A83EE@tv-sign.ru>
[-- Attachment #1: Type: text/plain, Size: 488 bytes --]
While rooting aroung in the signal code trying to understand how to
fix the SIG_IGN ploy (set sig handler to SIG_IGN and flood system with
high speed repeating timers) I came across what, I think, is a problem
in sigaction() in that when processing a SIG_IGN request it flushes
signals from 1 to SIGRTMIN and leaves the rest. The attached patch is
an attempt to fix this.
--
George Anzinger george@mvista.com
HRT (High-res-timers): http://sourceforge.net/projects/high-res-timers/
[-- Attachment #2: sigaction-fix.patch --]
[-- Type: text/plain, Size: 3026 bytes --]
Source: MontaVista Software, Inc.
Type: Defect Fix
Description:
It appeares that the sigaction system call, when processing a SIG_IGN or
a SIG_DFL, is removing only signals that appear in the first mask word.
Signed-off-by: George Anzinger <george@mvista.com>
include/linux/signal.h | 16 ++++++++++++++++
kernel/signal.c | 34 ++++++++++++++++++++++++++++++++--
2 files changed, 48 insertions(+), 2 deletions(-)
Index: linux-2.6.15-rc/kernel/signal.c
===================================================================
--- linux-2.6.15-rc.orig/kernel/signal.c
+++ linux-2.6.15-rc/kernel/signal.c
@@ -633,6 +633,33 @@ void signal_wake_up(struct task_struct *
* Returns 1 if any signals were found.
*
* All callers must be holding the siglock.
+ *
+ * This version takes a sigset mask and looks at all signals,
+ * not just those in the first mask word.
+ */
+static int rm_from_queue_full(sigset_t *mask, struct sigpending *s)
+{
+ struct sigqueue *q, *n;
+ sigset_t m;
+
+ sigandsets(&m, mask, &s->signal);
+ if (sigisemptyset(&m))
+ return 0;
+
+ signandsets(&s->signal, &s->signal, mask);
+ list_for_each_entry_safe(q, n, &s->list, list) {
+ if (sigismember(mask, q->info.si_signo)) {
+ list_del_init(&q->list);
+ __sigqueue_free(q);
+ }
+ }
+ return 1;
+}
+/*
+ * Remove signals in mask from the pending set and queue.
+ * Returns 1 if any signals were found.
+ *
+ * All callers must be holding the siglock.
*/
static int rm_from_queue(unsigned long mask, struct sigpending *s)
{
@@ -2471,6 +2498,7 @@ int
do_sigaction(int sig, const struct k_sigaction *act, struct k_sigaction *oact)
{
struct k_sigaction *k;
+ sigset_t mask;
if (!valid_signal(sig) || sig < 1 || (act && sig_kernel_only(sig)))
return -EINVAL;
@@ -2518,9 +2546,11 @@ do_sigaction(int sig, const struct k_sig
*k = *act;
sigdelsetmask(&k->sa.sa_mask,
sigmask(SIGKILL) | sigmask(SIGSTOP));
- rm_from_queue(sigmask(sig), &t->signal->shared_pending);
+ sigemptyset(&mask);
+ sigaddset(&mask, sig);
+ rm_from_queue_full(&mask, &t->signal->shared_pending);
do {
- rm_from_queue(sigmask(sig), &t->pending);
+ rm_from_queue_full(&mask, &t->pending);
recalc_sigpending_tsk(t);
t = next_thread(t);
} while (t != current);
Index: linux-2.6.15-rc/include/linux/signal.h
===================================================================
--- linux-2.6.15-rc.orig/include/linux/signal.h
+++ linux-2.6.15-rc/include/linux/signal.h
@@ -82,6 +82,22 @@ static inline int sigfindinword(unsigned
#endif /* __HAVE_ARCH_SIG_BITOPS */
+static inline int sigisemptyset(sigset_t *set)
+{
+ extern void _NSIG_WORDS_is_unsupported_size(void);
+ switch (_NSIG_WORDS) {
+ case 4:
+ return (set->sig[3] | set->sig[2] |
+ set->sig[1] | set->sig[0]) == 0;
+ case 2:
+ return (set->sig[1] | set->sig[0]) == 0;
+ case 1:
+ return set->sig[0] == 0;
+ default:
+ _NSIG_WORDS_is_unsupported_size();
+ }
+}
+
#define sigmask(sig) (1UL << ((sig) - 1))
#ifndef __HAVE_ARCH_SIG_SETOPS
next prev parent reply other threads:[~2005-11-16 23:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-05 1:36 [PATCH] Additional/catchup RCU signal fixes for -mm Paul E. McKenney
2005-11-05 16:32 ` Oleg Nesterov
2005-11-06 1:00 ` Paul E. McKenney
2005-11-06 14:17 ` Oleg Nesterov
2005-11-06 14:46 ` Oleg Nesterov
2005-11-06 23:02 ` Paul E. McKenney
2005-11-06 14:32 ` Posix timers vs exec problems Oleg Nesterov
2005-11-07 18:12 ` [PATCH] fix de_thread() vs send_group_sigqueue() race Oleg Nesterov
2005-11-08 20:36 ` Chris Wright
2005-11-08 20:55 ` Linus Torvalds
2005-11-16 23:26 ` George Anzinger [this message]
2005-11-22 1:09 ` Thread group exec race -> null pointer... HELP George Anzinger
2005-11-22 14:45 ` Oleg Nesterov
2005-11-23 20:30 ` George Anzinger
2005-11-25 15:03 ` Ingo Molnar
2005-11-22 19:20 ` [PATCH] fix do_wait() vs exec() race Oleg Nesterov
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=437BC01D.60302@mvista.com \
--to=george@mvista.com \
--cc=akpm@osdl.org \
--cc=dipankar@in.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@tv-sign.ru \
--cc=paulmck@us.ibm.com \
--cc=roland@redhat.com \
--cc=suzannew@cs.pdx.edu \
/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