Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1262489
| From | Oleg Nesterov <oleg@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal() |
| Date | 2015-11-04 19:30 +0100 |
| Message-ID | <qraYN-411-7@gated-at.bofh.it> (permalink) |
| References | <qqnln-5Pq-17@gated-at.bofh.it> <qqo7N-6lo-13@gated-at.bofh.it> <qqpwS-745-21@gated-at.bofh.it> <qqqVZ-83U-23@gated-at.bofh.it> <qraYN-411-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
complete_signal() checks SIGNAL_UNKILLABLE before it starts to destroy the
thread group, today this is unnecessary and even not 100% correct.
After the commit f008faff0e27 ("signals: protect init from unwanted signals
more") we rely on sig_task_ignored(), complete_signal(SIGKILL) can only see
a SIGNAL_UNKILLABLE task if we actually want to kill it. And note that after
the commit b3bfa0cba867 ("signals: protect cinit from blocked fatal signals")
we do not drop SIGKILL dequeued by /sbin/init.
And it does not look right. fatal_signal_pending() should always imply that
the whole thread group (except ->group_exit_task if it is not NULL) is killed,
this check breaks the rule.
This explains WARN_ON(!JOBCTL_STOP_PENDING) in task_participate_group_stop()
triggered by the test-case from Dmitry:
int main()
{
int pid = 1;
ptrace(PTRACE_ATTACH, pid, 0, 0);
ptrace(PTRACE_SETOPTIONS, pid, 0, PTRACE_O_EXITKILL);
sleep(1);
return 0;
}
do_signal_stop()->signal_group_exit() returns false because SIGNAL_GROUP_EXIT
is not set, but task_set_jobctl_pending() checks fatal_signal_pending() and
does not set JOBCTL_STOP_PENDING.
The test-case above needs root and (correctly) crashes the kernel, but we can
trigger the same warning inside the container or using another test-case:
static int init(void *arg)
{
for (;;)
pause();
}
int main(void)
{
char stack[16 * 1024];
for (;;) {
int pid = clone(init, stack + sizeof(stack)/2,
CLONE_NEWPID | SIGCHLD, NULL);
assert(pid > 0);
assert(ptrace(PTRACE_ATTACH, pid, 0, 0) == 0);
assert(waitpid(-1, NULL, WSTOPPED) == pid);
assert(ptrace(PTRACE_DETACH, pid, 0, SIGSTOP) == 0);
assert(syscall(__NR_tkill, pid, SIGKILL) == 0);
assert(pid == wait(NULL));
}
}
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
---
kernel/signal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/kernel/signal.c b/kernel/signal.c
index d64efad..9b6f385 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -914,7 +914,7 @@ static void complete_signal(int sig, struct task_struct *p, int group)
* then start taking the whole group down immediately.
*/
if (sig_fatal(p, sig) &&
- !(signal->flags & (SIGNAL_UNKILLABLE | SIGNAL_GROUP_EXIT)) &&
+ !(signal->flags & SIGNAL_GROUP_EXIT) &&
!sigismember(&t->real_blocked, sig) &&
(sig == SIGKILL || !t->ptrace)) {
/*
--
1.5.5.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
WARNING in task_participate_group_stop Dmitry Vyukov <dvyukov@google.com> - 2015-11-02 14:30 +0100
Re: WARNING in task_participate_group_stop Oleg Nesterov <oleg@redhat.com> - 2015-11-02 15:20 +0100
Re: WARNING in task_participate_group_stop Dmitry Vyukov <dvyukov@google.com> - 2015-11-02 15:30 +0100
Re: WARNING in task_participate_group_stop Oleg Nesterov <oleg@redhat.com> - 2015-11-02 15:40 +0100
Re: WARNING in task_participate_group_stop Oleg Nesterov <oleg@redhat.com> - 2015-11-02 16:50 +0100
Re: WARNING in task_participate_group_stop Oleg Nesterov <oleg@redhat.com> - 2015-11-02 18:20 +0100
[PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal() Oleg Nesterov <oleg@redhat.com> - 2015-11-04 19:30 +0100
Re: [PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal() Andrew Morton <akpm@linux-foundation.org> - 2015-11-05 02:30 +0100
Re: [PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal() Oleg Nesterov <oleg@redhat.com> - 2015-11-05 16:20 +0100
Re: [PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal() Oleg Nesterov <oleg@redhat.com> - 2015-11-05 18:10 +0100
[PATCH 0/1] (Was: WARNING in task_participate_group_stop) Oleg Nesterov <oleg@redhat.com> - 2015-11-04 19:30 +0100
csiph-web