From: Thomas Gleixner <tglx@linutronix.de>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Oleg Nesterov <oleg@redhat.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>,
Michael Kerrisk <mtk.manpages@gmail.com>,
linux-man@vger.kernel.org, libc-alpha@sourceware.org
Subject: Re: signals: Bug or manpage inconsistency?
Date: Tue, 30 May 2017 18:14:26 +0200 (CEST) [thread overview]
Message-ID: <alpine.DEB.2.20.1705301750390.1950@nanos> (raw)
In-Reply-To: <alpine.DEB.2.20.1705301402270.1950@nanos>
On Tue, 30 May 2017, Thomas Gleixner wrote:
> The commit which added the queuing of blocked and ignored signals is in the
> history tree with a pretty useless changelog.
>
> https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
>
> commit 98fc8ab9e74389e0c7001052597f61336dc62833
> Author: Linus Torvalds <torvalds@penguin.transmeta.com>
> Date: Tue Feb 11 20:49:03 2003 -0800
>
> Don't wake up processes unnecessarily for ignored signals
>
> It rewrites sig_ignored() and adds the following to it:
>
> + /*
> + * Blocked signals are never ignored, since the
> + * signal handler may change by the time it is
> + * unblocked.
> + */
> + if (sigismember(&t->blocked, sig))
> + return 0;
>
> I have no idea how that is related to $subject of the commit and why this
> decision was made.
>
> Linus, any recollection?
So I found at least some explanation by studying the spec some more.
There are two variants of ignored signals:
1) handler is SIG_IGN
2) handler is SIG_DFL and default action is 'ignore'
These are the signals in SIG_KERNEL_IGNORE_MASK
#define SIG_KERNEL_IGNORE_MASK (\
rt_sigmask(SIGCONT) | rt_sigmask(SIGCHLD) | \
rt_sigmask(SIGWINCH) | rt_sigmask(SIGURG) )
These signals are not allowed to be discarded when the signal is
blocked.
So my understanding of the spec is:
#1 Can discard the signals as long as SIG_IGN is set whether the signal
is blocked or not
#2 Must queue them if the signal is blocked, otherwise discard
I changed the logic according to this with the patch below and a quick test
run of lpt and glibc test cases produces no failures.
Thoughts?
Thanks,
tglx
8<--------------------
Subject: signals: Reduce scope of blocked signals in sig_handler_ignored()
From: Thomas Gleixner <tglx@linutronix.de>
Date: Tue, 30 May 2017 18:01:33 +0200
Add proper changelog and a big fat comment in the code.
Not-yet-signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/signal.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Index: b/kernel/signal.c
===================================================================
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -70,6 +70,13 @@ static int sig_handler_ignored(void __us
(handler == SIG_DFL && sig_kernel_ignore(sig));
}
+static int sig_handler_is_sigign(struct task_struct *t, int sig)
+{
+ void __user *handler = sig_handler(t, sig);
+
+ return handler == SIG_IGN;
+}
+
static int sig_task_ignored(struct task_struct *t, int sig, bool force)
{
void __user *handler;
@@ -91,7 +98,7 @@ static int sig_ignored(struct task_struc
* unblocked.
*/
if (sigismember(&t->blocked, sig) || sigismember(&t->real_blocked, sig))
- return 0;
+ return sig_handler_is_sigign(t, sig);
if (!sig_task_ignored(t, sig, force))
return 0;
next prev parent reply other threads:[~2017-05-30 16:14 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-30 13:21 Thomas Gleixner
2017-05-30 16:14 ` Thomas Gleixner [this message]
2017-05-30 17:04 ` Oleg Nesterov
2017-05-30 17:19 ` Linus Torvalds
2017-05-30 19:18 ` Oleg Nesterov
2017-05-30 20:54 ` Thomas Gleixner
2017-05-31 0:48 ` Eric W. Biederman
2017-05-31 1:10 ` Eric W. Biederman
2017-05-30 17:04 ` Linus Torvalds
2017-05-30 19:35 ` Thomas Gleixner
2017-05-30 19:58 ` Linus Torvalds
2017-05-30 21:00 ` Thomas Gleixner
2017-05-31 6:51 ` Michael Kerrisk (man-pages)
2017-06-01 7:01 ` Eric W. Biederman
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=alpine.DEB.2.20.1705301750390.1950@nanos \
--to=tglx@linutronix.de \
--cc=libc-alpha@sourceware.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-man@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--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®