Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5236519imm; Tue, 31 Jul 2018 07:41:52 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfAT6cZSOekaPJYiT6kl5DCf+1vhKMWi/6D1Zb38JDc6NFbC47QEqm2n1gIPKyHVRXOqNwL X-Received: by 2002:aa7:83cd:: with SMTP id j13-v6mr22721952pfn.236.1533048112450; Tue, 31 Jul 2018 07:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533048112; cv=none; d=google.com; s=arc-20160816; b=If4ZEZymzSUo1HinWQNSPsmPTXzeZHSolBxRPY8801PvgwxsQ6kPiaWiS9+YXinq02 rOt9B1AxwZeMk5HdKvYjylfU9HoVZPKDIFihOZmCWKeom45hU7TpEDSfa9ezovxkVpXy whaEE5FVhK+jMDyuKpmTwdM8xg7jg4J9g6mIMEbOQNv5Lg4fk0etuGs84BNuM9+KRvh7 ZYHzFZTT1FumTKMghrNJBjQw6BhwEEbfejF3OpyTQiQvuH+3AWKAcxQePbtT1LjkKq1x 8j2omPfX0WDeyDO/ZOtZxEKfkioGthCqj++AppZc94pfxrxUqbRFXbBIwa9ETOVpw9L9 ilsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=7exeFmE9CVz546DlLjKuAZwupj39GzgW0jfBzkOtFTM=; b=oPieLlY/raedl2GE/ELKYImsI/gE4x3dVs1b6b2zXHnAwQygOSpS1dMAaI5XVqrg2N pAIy6erj6fcs2A1xepB3k7TgG62k41LhJ2ffz/gIw68SeQeyEofx6rWyGbzALOcyREYD SZ7bSoQoaOCKMn1uOwFxMW87V2B27H8LvF8HBh35tKXumMbJfUZvih+spgGkeLDws93+ Ws1nBV/AgMSTjCH1crvHrNoNvmYRjOhBqOzC1Pp+NhEE2J9ppUHHtUH+rgJDVf2sH08V O412ZV3zo71aUdc2kvwC6giJhm+UT+E748UYE5hOeoWjayImbzMGYMTQ8K0pyLY37HeZ FmxQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s10-v6si11856596pgm.501.2018.07.31.07.41.38; Tue, 31 Jul 2018 07:41:52 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732439AbeGaQUb (ORCPT + 99 others); Tue, 31 Jul 2018 12:20:31 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:60846 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732361AbeGaQUa (ORCPT ); Tue, 31 Jul 2018 12:20:30 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3AA588198B06; Tue, 31 Jul 2018 14:39:52 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.34.27.30]) by smtp.corp.redhat.com (Postfix) with SMTP id 166701C4C3; Tue, 31 Jul 2018 14:39:50 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Tue, 31 Jul 2018 16:39:52 +0200 (CEST) Date: Tue, 31 Jul 2018 16:39:50 +0200 From: Oleg Nesterov To: =?iso-8859-1?Q?J=FCrg?= Billeter Cc: Andrew Morton , Thomas Gleixner , Eric Biederman , linux-api@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] prctl: add PR_[GS]ET_KILLABLE Message-ID: <20180731143949.GA1890@redhat.com> References: <20180730075241.24002-1-j@bitron.ch> <20180731070337.61004-1-j@bitron.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180731070337.61004-1-j@bitron.ch> User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 31 Jul 2018 14:39:52 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 31 Jul 2018 14:39:52 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'oleg@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 07/31, J?rg Billeter wrote: > > PR_SET_KILLABLE clears the SIGNAL_UNKILLABLE flag. This allows > CLONE_NEWPID tasks to restore normal signal behavior, opting out of the > special signal protection for init processes. This prctl does not allow > setting the SIGNAL_UNKILLABLE flag, only clearing. > > The SIGNAL_UNKILLABLE flag, which is implicitly set for tasks cloned > with CLONE_NEWPID, has the effect of ignoring all signals (from > userspace) if the corresponding handler is set to SIG_DFL. The only > exceptions are SIGKILL and SIGSTOP and they are only accepted if raised > from an ancestor namespace. > > 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? 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? > * 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. > * 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? Let me clarify. I am not arguing with this patch, probably it makes sense in any case. I am just trying to understand your real motivation for this change. > + 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(). Oleg.