From: Roland McGrath <roland@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>, linux-kernel@vger.kernel.org
Subject: [PATCH 11/23] tracehook: tracehook_consider_ignored_signal
Date: Thu, 17 Jul 2008 00:30:11 -0700 (PDT) [thread overview]
Message-ID: <20080717073011.DC1B01541A5@magilla.localdomain> (raw)
In-Reply-To: Roland McGrath's message of Thursday, 17 July 2008 00:25:41 -0700 <20080717072541.F390E15411D@magilla.localdomain>
This defines tracehook_consider_ignored_signal() has a fine-grained
hook for deciding to prevent the normal short-circuit of sending an
ignored signal, as ptrace does. There is no change, only cleanup.
Signed-off-by: Roland McGrath <roland@redhat.com>
---
include/linux/tracehook.h | 19 +++++++++++++++++++
kernel/signal.c | 27 ++++++++++++++++-----------
2 files changed, 35 insertions(+), 11 deletions(-)
diff --git a/include/linux/tracehook.h b/include/linux/tracehook.h
index 2d1426f..8cffd34 100644
--- a/include/linux/tracehook.h
+++ b/include/linux/tracehook.h
@@ -312,4 +312,23 @@ static inline void tracehook_signal_handler(int sig, siginfo_t *info,
ptrace_notify(SIGTRAP);
}
+/**
+ * tracehook_consider_ignored_signal - suppress short-circuit of ignored signal
+ * @task: task receiving the signal
+ * @sig: signal number being sent
+ * @handler: %SIG_IGN or %SIG_DFL
+ *
+ * Return zero iff tracing doesn't care to examine this ignored signal,
+ * so it can short-circuit normal delivery and never even get queued.
+ * Either @handler is %SIG_DFL and @sig's default is ignore, or it's %SIG_IGN.
+ *
+ * Called with @task->sighand->siglock held.
+ */
+static inline int tracehook_consider_ignored_signal(struct task_struct *task,
+ int sig,
+ void __user *handler)
+{
+ return (task_ptrace(task) & PT_PTRACED) != 0;
+}
+
#endif /* <linux/tracehook.h> */
diff --git a/kernel/signal.c b/kernel/signal.c
index 02d3a11..f68fb01 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -22,6 +22,7 @@
#include <linux/ptrace.h>
#include <linux/signal.h>
#include <linux/signalfd.h>
+#include <linux/tracehook.h>
#include <linux/capability.h>
#include <linux/freezer.h>
#include <linux/pid_namespace.h>
@@ -39,24 +40,21 @@
static struct kmem_cache *sigqueue_cachep;
-static int __sig_ignored(struct task_struct *t, int sig)
+static void __user *sig_handler(struct task_struct *t, int sig)
{
- void __user *handler;
+ return t->sighand->action[sig - 1].sa.sa_handler;
+}
+static int sig_handler_ignored(void __user *handler, int sig)
+{
/* Is it explicitly or implicitly ignored? */
-
- handler = t->sighand->action[sig - 1].sa.sa_handler;
return handler == SIG_IGN ||
(handler == SIG_DFL && sig_kernel_ignore(sig));
}
static int sig_ignored(struct task_struct *t, int sig)
{
- /*
- * Tracers always want to know about signals..
- */
- if (t->ptrace & PT_PTRACED)
- return 0;
+ void __user *handler;
/*
* Blocked signals are never ignored, since the
@@ -66,7 +64,14 @@ static int sig_ignored(struct task_struct *t, int sig)
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
return 0;
- return __sig_ignored(t, sig);
+ handler = sig_handler(t, sig);
+ if (!sig_handler_ignored(handler, sig))
+ return 0;
+
+ /*
+ * Tracers may want to know about even ignored signals.
+ */
+ return !tracehook_consider_ignored_signal(t, sig, handler);
}
/*
@@ -2324,7 +2329,7 @@ int do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
* (for example, SIGCHLD), shall cause the pending signal to
* be discarded, whether or not it is blocked"
*/
- if (__sig_ignored(t, sig)) {
+ if (sig_handler_ignored(sig_handler(t, sig), sig)) {
sigemptyset(&mask);
sigaddset(&mask, sig);
rm_from_queue_full(&mask, &t->signal->shared_pending);
next prev parent reply other threads:[~2008-07-17 7:31 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-17 7:25 [PATCH 00/23] tracehook Roland McGrath
2008-07-17 7:27 ` [PATCH 01/23] tracehook: add linux/tracehook.h Roland McGrath
2008-07-17 8:48 ` Alexey Dobriyan
2008-07-17 11:06 ` Petr Tesarik
2008-07-17 21:50 ` Alexey Dobriyan
2008-07-17 13:34 ` Christoph Hellwig
2008-07-18 11:57 ` Petr Tesarik
2008-07-17 7:28 ` [PATCH 02/23] tracehook: exec Roland McGrath
2008-07-21 8:49 ` Christoph Hellwig
2008-07-17 7:28 ` [PATCH 03/23] tracehook: unexport ptrace_notify Roland McGrath
2008-07-17 7:28 ` [PATCH 04/23] tracehook: exit Roland McGrath
2008-07-17 7:29 ` [PATCH 05/23] tracehook: clone Roland McGrath
2008-07-17 7:29 ` [PATCH 06/23] tracehook: vfork-done Roland McGrath
2008-07-17 7:29 ` [PATCH 07/23] tracehook: release_task Roland McGrath
2008-07-17 7:29 ` [PATCH 08/23] tracehook: tracehook_tracer_task Roland McGrath
2008-07-17 7:29 ` [PATCH 09/23] tracehook: tracehook_expect_breakpoints Roland McGrath
2008-07-17 7:30 ` [PATCH 10/23] tracehook: tracehook_signal_handler Roland McGrath
2008-07-17 7:30 ` Roland McGrath [this message]
2008-07-17 7:30 ` [PATCH 12/23] tracehook: tracehook_consider_fatal_signal Roland McGrath
2008-07-17 7:30 ` [PATCH 13/23] tracehook: syscall Roland McGrath
2008-07-17 7:30 ` [PATCH 14/23] tracehook: get_signal_to_deliver Roland McGrath
2008-07-17 7:30 ` [PATCH 15/23] tracehook: job control Roland McGrath
2008-07-17 7:30 ` [PATCH 16/23] tracehook: death Roland McGrath
2008-07-17 7:30 ` [PATCH 17/23] tracehook: force signal_pending() Roland McGrath
2008-07-17 7:31 ` [PATCH 18/23] tracehook: TIF_NOTIFY_RESUME Roland McGrath
2008-07-17 7:31 ` [PATCH 19/23] tracehook: asm/syscall.h Roland McGrath
2008-07-17 7:31 ` [PATCH 20/23] tracehook: CONFIG_HAVE_ARCH_TRACEHOOK Roland McGrath
2008-07-17 7:31 ` [PATCH 21/23] tracehook: wait_task_inactive Roland McGrath
2008-07-17 7:31 ` [PATCH 22/23] task_current_syscall Roland McGrath
2008-07-17 7:31 ` [PATCH 23/23] /proc/PID/syscall Roland McGrath
2008-07-17 22:56 ` Alexey Dobriyan
2008-07-21 8:19 ` Roland McGrath
2008-07-17 7:39 ` [PATCH 00/23] tracehook Andrew Morton
2008-07-17 8:11 ` Roland McGrath
2008-07-17 8:30 ` Andrew Morton
2008-07-17 8:37 ` Roland McGrath
2008-07-17 8:51 ` Andrew Morton
2008-07-18 8:07 ` Ingo Molnar
2008-07-21 9:59 ` Roland McGrath
2008-07-18 9:20 ` David Miller
2008-07-18 11:24 ` Andi Kleen
2008-07-18 11:32 ` David Miller
2008-07-21 10:54 ` Roland McGrath
2008-07-21 15:18 ` David Miller
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=20080717073011.DC1B01541A5@magilla.localdomain \
--to=roland@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.org \
/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
all inboxes | Powered by JetHome®