From: Oleg Nesterov <oleg@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>,
Pavel Emelyanov <xemul@openvz.org>,
Roland McGrath <roland@redhat.com>,
"Serge E. Hallyn" <serue@us.ibm.com>,
Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] simplify sig_ignored() pathes
Date: Tue, 18 Nov 2008 18:59:05 +0100 [thread overview]
Message-ID: <20081118175905.GA17142@redhat.com> (raw)
The code which checks for ignored signals is a bit overcomplicated
because tracehook_consider_ignored_signal() wants the "handler" arg.
Can't we kill it? It is not used even with utrace, and even if it will
be used later it is OK to read ->sighand again in the slow path.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
--- K-IS/include/linux/tracehook.h~2_SIG_IGNORED 2008-11-10 19:21:17.000000000 +0100
+++ K-IS/include/linux/tracehook.h 2008-11-17 22:01:28.000000000 +0100
@@ -388,17 +388,14 @@ static inline void tracehook_signal_hand
* 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)
+ int sig)
{
return (task_ptrace(task) & PT_PTRACED) != 0;
}
--- K-IS/kernel/signal.c~2_SIG_IGNORED 2008-11-17 19:54:09.000000000 +0100
+++ K-IS/kernel/signal.c 2008-11-17 22:01:28.000000000 +0100
@@ -41,44 +41,33 @@
static struct kmem_cache *sigqueue_cachep;
-static void __user *sig_handler(struct task_struct *t, int sig)
+static int sig_task_ignored(struct task_struct *t, int sig)
{
void __user *h = t->sighand->action[sig - 1].sa.sa_handler;
- /* drop SIGKILL early to not confuse wait_xxx_killable/etc */
- if (unlikely(t->signal->flags & SIGNAL_UNKILLABLE) && h == SIG_DFL)
- h = SIG_IGN;
-
- return h;
-}
-
-static int sig_handler_ignored(void __user *handler, int sig)
-{
- /* Is it explicitly or implicitly ignored? */
- return handler == SIG_IGN ||
- (handler == SIG_DFL && sig_kernel_ignore(sig));
+ if (h == SIG_DFL) {
+ /* init drops SIGKILL early to not confuse xxx_killable/etc */
+ return sig_kernel_ignore(sig) ||
+ unlikely(t->signal->flags & SIGNAL_UNKILLABLE);
+ }
+ return h == SIG_IGN;
}
static int sig_ignored(struct task_struct *t, int sig)
{
- void __user *handler;
-
/*
* Blocked signals are never ignored, since the
* signal handler may change by the time it is
* unblocked.
*/
- if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
- return 0;
-
- handler = sig_handler(t, sig);
- if (!sig_handler_ignored(handler, sig))
+ if (sigismember(&t->blocked, sig) ||
+ sigismember(&t->real_blocked, sig) ||
+ !sig_task_ignored(t, sig))
return 0;
-
/*
* Tracers may want to know about even ignored signals.
*/
- return !tracehook_consider_ignored_signal(t, sig, handler);
+ return !tracehook_consider_ignored_signal(t, sig);
}
/*
@@ -2338,7 +2327,7 @@ int do_sigaction(int sig, struct k_sigac
* (for example, SIGCHLD), shall cause the pending signal to
* be discarded, whether or not it is blocked"
*/
- if (sig_handler_ignored(sig_handler(t, sig), sig)) {
+ if (sig_task_ignored(t, sig)) {
sigemptyset(&mask);
sigaddset(&mask, sig);
rm_from_queue_full(&mask, &t->signal->shared_pending);
next reply other threads:[~2008-11-18 16:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-18 17:59 Oleg Nesterov [this message]
2008-11-19 18:53 ` [PATCH 2/2] simplify sig_ignored() pathes Roland McGrath
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=20081118175905.GA17142@redhat.com \
--to=oleg@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=ebiederm@xmission.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roland@redhat.com \
--cc=serue@us.ibm.com \
--cc=sukadev@linux.vnet.ibm.com \
--cc=xemul@openvz.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.