Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1696592imm; Wed, 8 Aug 2018 23:58:40 -0700 (PDT) X-Google-Smtp-Source: AA+uWPy1bzKBoGSCe7ZF2wEmMC1guu2CXTkcjAJaYUTxTN+tF40I19/NpGcdYNUKWLN3Oi6M7Cks X-Received: by 2002:a63:fc0a:: with SMTP id j10-v6mr914939pgi.1.1533797920226; Wed, 08 Aug 2018 23:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533797920; cv=none; d=google.com; s=arc-20160816; b=XX6o9dUqKjFjNybnS4cQ0rpRSfhmMtn8Icx0s8N1B7PIkLg8aG2uH/pIa9jschVQS4 VhxtozWNsjM4nnOJlbUGjYE7v6zx+kDEM6JXdvCavNbygvVHar09n5XT0JdoINNqVtAe OeJeyYvxTUTGeB4igRGrTi3gGz0hkWUSs+RYh1Xtt4UmqrqUjRkStLA/MWWSbRi3JONi +6q4yniH2tagCUq+JMcZRwCr798kMrrjwPuvPkCOshXzZ2phSjFJzzmXkCdmEsdEDz5v XHph8Nev0HeHJBJzo7DSHz1mH6nkEHlsDRQcbZ8cfIERVjTSmHAtalo6HLy2/r76jIWY /aHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:references:in-reply-to:message-id :date:cc:to:from:arc-authentication-results; bh=VaSAbmpp8Xm2/zZozRU3MWcWKD72dBu/vriWnKMclHw=; b=nJKFgmNyJfXNKhLRO/OwYPOomGBTQNRCrjChiQxqIQyFuDd0rKfj2kySEMFb8a1fmt 70/M0RENy3hIFD6DGcPhqrl05CetsxE/GX9Z/1FqsvZbXbgPBNS6LsHbd3+fSFcvopTD SYvDNiiMtFYhBbQyyH8UFkHgimx0VR8DqqddSBkpxGgq/RPYp9/tW/Wgs1DT4zKy+d5C t6EvcVw5ZdfiHXclE+kU9BWPyUQbXsT8BrPmzbI8SqxezyyBtpE+WlKCq9oyJ1JeNC65 5e5RwJGaO1448QBO1NAFacJS84fLfilCvTR9/R4ERj40wZgWMqdIOD0AyV0FbvFtPrfQ ex0g== 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 bi1-v6si5225779plb.399.2018.08.08.23.58.26; Wed, 08 Aug 2018 23:58:40 -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 S1728267AbeHIJUy (ORCPT + 99 others); Thu, 9 Aug 2018 05:20:54 -0400 Received: from out01.mta.xmission.com ([166.70.13.231]:43850 "EHLO out01.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbeHIJUx (ORCPT ); Thu, 9 Aug 2018 05:20:53 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fnesy-0008Iu-3p; Thu, 09 Aug 2018 00:57:28 -0600 Received: from [97.119.167.31] (helo=x220.int.ebiederm.org) by in02.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.87) (envelope-from ) id 1fnesi-00054s-O5; Thu, 09 Aug 2018 00:57:27 -0600 From: "Eric W. Biederman" To: Oleg Nesterov Cc: Andrew Morton , linux-kernel@vger.kernel.org, Wen Yang , majiang , Linus Torvalds , "Eric W. Biederman" Date: Thu, 9 Aug 2018 01:56:01 -0500 Message-Id: <20180809065605.32345-2-ebiederm@xmission.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <87wot0yqsx.fsf_-_@xmission.com> References: <87wot0yqsx.fsf_-_@xmission.com> X-XM-SPF: eid=1fnesi-00054s-O5;;;mid=<20180809065605.32345-2-ebiederm@xmission.com>;;;hst=in02.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1878QsZtDqGDNGqZNTE9hguniNML2oWnEA= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa07.xmission.com X-Spam-Level: X-Spam-Status: No, score=0.5 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,XMSubLong autolearn=disabled version=3.4.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4990] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=31] X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=31 X-Spam-Combo: ;Oleg Nesterov X-Spam-Relay-Country: X-Spam-Timing: total 15024 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 3.0 (0.0%), b_tie_ro: 2.2 (0.0%), parse: 0.94 (0.0%), extract_message_metadata: 11 (0.1%), get_uri_detail_list: 1.17 (0.0%), tests_pri_-1000: 3.0 (0.0%), tests_pri_-950: 1.13 (0.0%), tests_pri_-900: 0.95 (0.0%), tests_pri_-400: 19 (0.1%), check_bayes: 18 (0.1%), b_tokenize: 7 (0.0%), b_tok_get_all: 5 (0.0%), b_comp_prob: 1.88 (0.0%), b_tok_touch_all: 2.2 (0.0%), b_finish: 0.84 (0.0%), tests_pri_0: 128 (0.9%), check_dkim_signature: 0.58 (0.0%), check_dkim_adsp: 3.3 (0.0%), tests_pri_500: 14855 (98.9%), poll_dns_idle: 14845 (98.8%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH v5 2/6] fork: Unconditionally exit if a fatal signal is pending X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In practice this does not change anything as testing for fatal_signal_pending and exiting for with an error code duplicates the work of the next clause which recalculates pending signals and then exits fork if any are pending. In both cases the pending signal will trigger the slow path when existing to userspace, and the fatal signal will cause do_exit to be called. The advantage of making this a separate test is that it makes it clear processing the fatal signal will terminate the fork, and it allows the rest of the signal logic to be updated without fear that this important case will be lost. Signed-off-by: "Eric W. Biederman" --- kernel/fork.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index b9c54318a292..22d4cdb9a7ca 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1928,6 +1928,12 @@ static __latent_entropy struct task_struct *copy_process( goto bad_fork_cancel_cgroup; } + /* Let kill terminate clone/fork in the middle */ + if (fatal_signal_pending(current)) { + retval = -EINTR; + goto bad_fork_cancel_cgroup; + } + /* * Process group and session signals need to be delivered to just the * parent before the fork or both the parent and the child after the -- 2.17.1