mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Oleg Nesterov <oleg@redhat.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	Roland McGrath <roland@hack.frob.com>,
	amanieu@gmail.com, pmoore@redhat.com,
	Ingo Molnar <mingo@kernel.org>,
	vdavydov@parallels.com, qiaowei.ren@intel.com, dave@stgolabs.net,
	palmer@dabbelt.com, LKML <linux-kernel@vger.kernel.org>,
	syzkaller <syzkaller@googlegroups.com>,
	Kostya Serebryany <kcc@google.com>,
	Alexander Potapenko <glider@google.com>,
	Sasha Levin <sasha.levin@oracle.com>
Subject: Re: [PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal()
Date: Wed, 4 Nov 2015 17:21:23 -0800	[thread overview]
Message-ID: <20151104172123.590fcbf0e8904911eeab3e3d@linux-foundation.org> (raw)
In-Reply-To: <20151104191912.GB20578@redhat.com>

On Wed, 4 Nov 2015 20:19:12 +0100 Oleg Nesterov <oleg@redhat.com> wrote:

> 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));
> 		}
> 	}

I'm thinking this should be backported into -stable due to WARN_ONs and
kernel crashes.  And as f008faff0e27 is from 2009, that means all
kernels.

Your thoughts on this?

  reply	other threads:[~2015-11-05  1:21 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 13:25 WARNING in task_participate_group_stop Dmitry Vyukov
2015-11-02 15:13 ` Oleg Nesterov
2015-11-02 14:21   ` Dmitry Vyukov
2015-11-02 15:33     ` Oleg Nesterov
2015-11-02 16:36   ` Oleg Nesterov
2015-11-02 18:06     ` Oleg Nesterov
2015-11-04 19:18       ` [PATCH 0/1] (Was: WARNING in task_participate_group_stop) Oleg Nesterov
2015-11-04 19:19         ` [PATCH 1/1] signal: kill the obsolete SIGNAL_UNKILLABLE check in complete_signal() Oleg Nesterov
2015-11-05  1:21           ` Andrew Morton [this message]
2015-11-05 16:08             ` Oleg Nesterov
2015-11-05 18:02               ` 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=20151104172123.590fcbf0e8904911eeab3e3d@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=amanieu@gmail.com \
    --cc=dave@stgolabs.net \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=kcc@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=palmer@dabbelt.com \
    --cc=pmoore@redhat.com \
    --cc=qiaowei.ren@intel.com \
    --cc=roland@hack.frob.com \
    --cc=sasha.levin@oracle.com \
    --cc=syzkaller@googlegroups.com \
    --cc=vdavydov@parallels.com \
    /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®