linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Dmitry Vyukov <dvyukov@google.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	jolsa@redhat.com, Namhyung Kim <namhyung@kernel.org>,
	luca abeni <luca.abeni@santannapisa.it>,
	syzkaller <syzkaller@googlegroups.com>,
	Ivan Delalande <colona@arista.com>
Subject: Re: [PATCH 1/2] signal: Always notice exiting tasks
Date: Tue, 12 Feb 2019 17:50:23 +0100	[thread overview]
Message-ID: <20190212165022.GA29263@redhat.com> (raw)
In-Reply-To: <871s4dctci.fsf@xmission.com>

On 02/12, Eric W. Biederman wrote:
>
> > Here I was trying for the simple minimal change and I hit this landmine.
> > Which leaves me with the question of what should be semantics of signal
> > handling after exit.

Yes, currently it is undefined. Even signal_pending() is random.

> > I think from dim memory of previous conversations the desired semantics
> > look like:
> > a) Ignore all signal state except for SIGKILL.
> > b) Letting SIGKILL wake up the process should be sufficient.

signal_wake_up(true) to make fatal_signal_pending() == T, I think.

> Oleg any ideas on how to make PTRACE_EVENT_EXIT reliably killable?

My answer is very simple: PTRACE_EVENT_EXIT must not stop if the tracee was
killed by the "real" SIGKILL (not by group_exit/etc), that is all. But this
is another user-visible change, it can equally confuse, say, strace (albeit
not too much iiuc).

But this needs another discussion.

> diff --git a/kernel/signal.c b/kernel/signal.c
> index 99fa8ff06fd9..a1f154dca73c 100644
> --- a/kernel/signal.c
> +++ b/kernel/signal.c
> @@ -2544,6 +2544,9 @@ bool get_signal(struct ksignal *ksig)
>                 }
>
>         fatal:
> +               /* No more signals can be pending past this point */
> +               sigdelset(&current->pending.signal, SIGKILL);

Well, this is very confusing. In fact, this is not really correct. Say, we should
not remove the pending SIGKILL if we are going to call do_coredump(). This is
possible if ptrace_signal() was called, or after is_current_pgrp_orphaned() returns
false.

> +               clear_tsk_thread_flag(current, TIF_SIGPENDING);

I don't understand this change, it looks irrelevant. Possibly makes sense, but
this connects to "semantics of signal handling after exit".

OK, we need a minimal incremental fix for now. I'd suggest to replace

	ksig->info.si_signo = signr = SIGKILL;
	if (signal_group_exit(signal))
		goto fatal;

added by this patch with

	if (__fatal_signal_pending(current)) {
		ksig->info.si_signo = signr = SIGKILL;
		sigdelset(&current->pending.signal, SIGKILL);
		goto fatal;
	}

__fatal_signal_pending() is cheaper and looks more understandable.

Oleg.


  reply	other threads:[~2019-02-12 16:50 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-01 16:48 perf_event_open+clone = unkillable process Dmitry Vyukov
2019-02-01 17:06 ` Dmitry Vyukov
2019-02-02 18:30   ` Jiri Olsa
2019-02-03 15:21     ` Jiri Olsa
2019-02-04  9:27   ` Thomas Gleixner
2019-02-04  9:38     ` Dmitry Vyukov
2019-02-04 17:38       ` Thomas Gleixner
2019-02-05  3:00         ` Eric W. Biederman
2019-02-05  4:27           ` Eric W. Biederman
2019-02-05  6:07             ` Eric W. Biederman
2019-02-05 15:26               ` [RFC][PATCH] signal: Store pending signal exit in tsk.jobctl not in tsk.pending Eric W. Biederman
2019-02-06 12:09                 ` Dmitry Vyukov
2019-02-06 21:47                   ` Eric W. Biederman
2019-02-06 18:07                 ` Oleg Nesterov
2019-02-06 22:25                   ` Eric W. Biederman
2019-02-07  6:42                     ` [PATCH 0/2]: Fixing unkillable processes caused by SIGHUP timers Eric W. Biederman
2019-02-07  6:43                       ` [PATCH 1/2] signal: Always notice exiting tasks Eric W. Biederman
2019-02-11 14:13                         ` Oleg Nesterov
2019-02-12  0:42                           ` Eric W. Biederman
2019-02-12  8:18                             ` Eric W. Biederman
2019-02-12 16:50                               ` Oleg Nesterov [this message]
2019-02-13  3:58                                 ` Eric W. Biederman
2019-02-13  4:09                                 ` [PATCH] signal: Restore the stop PTRACE_EVENT_EXIT Eric W. Biederman
2019-02-13 13:55                                   ` Oleg Nesterov
2019-02-13 14:38                                   ` Oleg Nesterov
2019-02-13 14:58                                     ` Eric W. Biederman
2019-02-07  6:44                       ` [PATCH 2/2] signal: Better detection of synchronous signals Eric W. Biederman
2019-02-11 15:18                         ` Oleg Nesterov
2019-02-12  0:01                           ` Eric W. Biederman
2019-02-12 17:21                             ` Oleg Nesterov
2019-02-07 11:46                       ` [PATCH 0/2]: Fixing unkillable processes caused by SIGHUP timers Dmitry Vyukov

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=20190212165022.GA29263@redhat.com \
    --to=oleg@redhat.com \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=colona@arista.com \
    --cc=dvyukov@google.com \
    --cc=ebiederm@xmission.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luca.abeni@santannapisa.it \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=syzkaller@googlegroups.com \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).