Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5336150imm; Tue, 31 Jul 2018 09:14:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc9bg1pMlQaDuDcrF6L/2gMfWsq7CWfz2TNZ1kRgGRMQDDxYVX6eAQpM7EZQGytooCUgzCi X-Received: by 2002:a17:902:708b:: with SMTP id z11-v6mr20718372plk.262.1533053667653; Tue, 31 Jul 2018 09:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533053667; cv=none; d=google.com; s=arc-20160816; b=tJP3U0FxAhAm81d9C8Zx0St6fCRGZpyBgdY3D9WECYio6Y+D0uf7UjkUiuvGRHiRw3 W+4y53z94X4WgA7v2Wkbxe1jea9WSmxSPPwylOkj4I7/I3fzSDKYwG4+VXhDSlScUoT/ W9Iu8zTR3SDP1uei1sghBJbJUnsCEHrsZCM8fuGXKOC4iQm8g73zKPHPhEkGn+D7ELrN 8HWmEhdqqJuQR/GdKeX4mdCZXEdpzmN6rU6URhjm7S8V/rbLYyl67eJ24A9SfMCQiUQN Qpv/5w4WvMzWp8WuExCDHaywTDOc/mrBU0BvZvrAZE4/1PnTCkzQldJ531su8W9Vyvc+ 3Xvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=1yrb9F9a7bEr7tGxRaFTGMOwC9M7q5uBAJ78/FJ0iZY=; b=peS34Gstu3c5J+dKLwFKNs/sfLziijTV79uLjNcoykS1SrTqdTcNCkTlVoWfSgXJCy AM00dAecaaakPdWr5xQ7MzEw8Nq/GV1XbNDU60QDqeHmdQf8qdyiMPn/ZQVF0xR2XAHp 80RTpaZQyYJYHLfcdwTTxqimnxCcvgtrVur2cgfvhfslU6ZDbqID58gZwHMOp2zpLGA7 acPjSEWnpinN5tXob9nUDcjj4yaw79AhUhRUaAAuNb47Vfb4sMWst/AcDOZloYBfH3X8 eKcq4cYfljGi8BOdaw9fhlfvToiq4rSUKnhlyz/zsPpHGUqEkThuFXDeE1n0I12luoE0 CF4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 67-v6si15467682pfc.21.2018.07.31.09.14.12; Tue, 31 Jul 2018 09:14:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732438AbeGaRyC (ORCPT + 99 others); Tue, 31 Jul 2018 13:54:02 -0400 Received: from nov-007-i652.relay.mailchannels.net ([46.232.183.206]:4810 "EHLO nov-007-i652.relay.mailchannels.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727569AbeGaRyC (ORCPT ); Tue, 31 Jul 2018 13:54:02 -0400 X-Sender-Id: novatrend|x-authuser|juerg@bitron.ch Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id B7BD51B60371; Tue, 31 Jul 2018 16:12:56 +0000 (UTC) Received: from srv17.tophost.ch (swiss-ingress-2.mailchannels.ch [46.232.183.6]) by relay.mailchannels.net (Postfix) with ESMTPA id 5EAA61B60349; Tue, 31 Jul 2018 16:12:53 +0000 (UTC) X-Sender-Id: novatrend|x-authuser|juerg@bitron.ch Received: from srv17.tophost.ch (srv17.tophost.ch [193.33.128.141]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.15.2); Tue, 31 Jul 2018 16:12:56 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: novatrend|x-authuser|juerg@bitron.ch X-MailChannels-Auth-Id: novatrend X-Fearful-Name: 0dcebefa16f09016_1533053576195_3138394660 X-MC-Loop-Signature: 1533053576195:3064311778 X-MC-Ingress-Time: 1533053576195 Received: from [80.219.231.201] (port=50824 helo=jzen.bitron.ch) by srv17.tophost.ch with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fkXGT-00As6o-3W; Tue, 31 Jul 2018 18:12:49 +0200 Message-ID: Subject: Re: [PATCH v2] prctl: add PR_[GS]ET_KILLABLE From: =?ISO-8859-1?Q?J=FCrg?= Billeter To: Oleg Nesterov Cc: Andrew Morton , Thomas Gleixner , Eric Biederman , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 31 Jul 2018 18:12:48 +0200 In-Reply-To: <20180731143949.GA1890@redhat.com> References: <20180730075241.24002-1-j@bitron.ch> <20180731070337.61004-1-j@bitron.ch> <20180731143949.GA1890@redhat.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.4 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-AuthUser: juerg@bitron.ch Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-07-31 at 16:39 +0200, Oleg Nesterov wrote: > On 07/31, Jürg Billeter wrote: > > SIGINT, SIGQUIT and SIGTSTP are used in job control for ^C, ^\, ^Z. > > While a task with the SIGNAL_UNKILLABLE flag could install handlers for > > these signals, this is not sufficient to implement a shell that uses > > CLONE_NEWPID for child processes: > > Ah. My question wasn't clear, sorry. > > Could you explain your use-case? Why a shell wants to use > CLONE_NEWPID? To guarantee that there won't be any runaway processes, i.e., ensure that no descendants (background helper daemons or misbehaving processes) survive when the child process is terminated. And to prevent children from killing their ancestors. This is not something that can be always-on in all shells, but it could be an option for users that want this control/isolation. > And what do we actually want in, say, ^Z case? Just stop the child reaper > or may be it would be better to stop the whole pid namespace? Stopping the whole PID namespace would be interesting, however, I think this should be discussed separately if and when there is a proposal to support this. For now the process group is stopped, same as without PID namespaces. > > * As SIGSTOP is ignored when raised from the SIGNAL_UNKILLABLE process > > itself, it's not possible to implement the stop action in a custom > > SIGTSTP handler. > > Yes. So may be we actually want to change __isig() paths to use > SEND_SIG_FORCED (this is not that simple), or perhaps we can change > __send_signal() to not drop SIGSTOP sent to itself, or may be we can even > introduce SIG_DFL_EVEN_IF_INIT, I dunno. In my opinion, my patch is much simpler and also more general as it covers all scenarios where regular signal handling is required or desired for "init" processes, with minimal code changes (after PR_SET_KILLABLE, binaries that expect SIG_DFL to work can be executed without changes). > > * Many applications do not install handlers for these signals and > > thus, job control won't work properly with unmodified applications. > > I can't understand this. An application should be changed anyway to do > PR_SET_KILLABLE? PR_SET_KILLABLE can be called (e.g., by the shell) between clone() and execve(). (Some applications may have issues running as subreaper but that's a separate matter, signal handling will work as expected). > > + case PR_SET_KILLABLE: > > + if (arg2 != 1 || arg3 || arg4 || arg5) > > + return -EINVAL; > > + spin_lock_irq(&me->sighand->siglock); > > + me->signal->flags &= ~SIGNAL_UNKILLABLE; > > + spin_unlock_irq(&me->sighand->siglock); > > OK, but then you need to change the CLONE_PARENT/SIGNAL_UNKILLABLE check > in copy_process(). Good point, need a different check for the PID namespace root process in copy_process(). Thanks, Jürg