Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6506451imm; Mon, 23 Jul 2018 20:29:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfoAc05eghrehXOHRhTX/UArK0nawfn04uOehZZB9Dxl3NCgXB0Zuz59jb31SXs4lP4R0z2 X-Received: by 2002:a17:902:6b05:: with SMTP id o5-v6mr15378205plk.67.1532402952220; Mon, 23 Jul 2018 20:29:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532402952; cv=none; d=google.com; s=arc-20160816; b=s/6iSP+n66xEhhys3v8jOwTUjp7MF3tiQ0XHHkohIykfcDBGc6krILEdno2JpLrh1t Df6l/ALiyOH6O4kQtypTzlUJepOKnYH4+pmQskS7C8tUO99eHbb0UHt0RoP0AmswAcRk Wwi8CXk92URZw0w/t3gSBwdTOBlhuGy63m4m1kcJYJ0YXCqtE1fAvlsq6jGfHil2GEGn 0YB+o8JUGvUfCGMaXvbK+teLBss9aGp8XPdkFt7d2RFQCbTiWwg4OP1rmCSFPcicEcoZ nDXo3RxA+c8s5PguAPRnESHnPmbeTctAA00C0fnke2KIAP9bfeeaopDyCW4CDq0ut1FF Sypw== 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=Bgofr+G+LhtHct1ceHP8UMrRdL5B3OevLWP2jerxSICM/mBW1Hrdunm0/8w8yWTdTG 9k0mNFkVqwTcuEVcK3EGfx8FP3ViQKm6p7qj5Kaw5GIskV0xNzQAAyausp0C5cITxRCl 2m6iRmjyRx5nSt4d51BW0TAj5X2V63SRK61Wf9B6YRKr1qii8vmmwd3sXX4iAbPBeEU7 0ByeeVkraxBWBEP3SNn17leArsDiSeniQq+MorAJa5qvw2k4x0W/7UzXBabCo+NY2tyl U5v3uds08yd+/WFHEVrGao23oAgm8SSRH9KU/x/yIWIp7pU7rLR+g2sRIbFsdiYSYBKs HPeA== 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 cc6-v6si2499646plb.458.2018.07.23.20.28.57; Mon, 23 Jul 2018 20:29:12 -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 S2388487AbeGXEby (ORCPT + 99 others); Tue, 24 Jul 2018 00:31:54 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:51382 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388391AbeGXEbx (ORCPT ); Tue, 24 Jul 2018 00:31:53 -0400 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fhnz4-0007io-Ft; Mon, 23 Jul 2018 21:27:34 -0600 Received: from [97.119.167.31] (helo=x220.int.ebiederm.org) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.87) (envelope-from ) id 1fhnxd-0008AK-Kb; Mon, 23 Jul 2018 21:26:06 -0600 From: "Eric W. Biederman" To: Linus Torvalds Cc: Oleg Nesterov , Andrew Morton , linux-kernel@vger.kernel.org, Wen Yang , majiang , "Eric W. Biederman" Date: Mon, 23 Jul 2018 22:24:16 -0500 Message-Id: <20180724032419.20231-17-ebiederm@xmission.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <87efft5ncd.fsf_-_@xmission.com> References: <87efft5ncd.fsf_-_@xmission.com> X-XM-SPF: eid=1fhnxd-0008AK-Kb;;;mid=<20180724032419.20231-17-ebiederm@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=97.119.167.31;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX19iARrmvzGQ6yn/GUyULcNKf6Im+6Oeon8= X-SA-Exim-Connect-IP: 97.119.167.31 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sa02.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,XMNoVowels,XMSubLong autolearn=disabled version=3.4.0 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4999] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa02 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa02 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 394 ms - load_scoreonly_sql: 0.05 (0.0%), signal_user_changed: 3.4 (0.9%), b_tie_ro: 2.3 (0.6%), parse: 1.08 (0.3%), extract_message_metadata: 24 (6.1%), get_uri_detail_list: 1.83 (0.5%), tests_pri_-1000: 10 (2.5%), tests_pri_-950: 2.1 (0.5%), tests_pri_-900: 1.70 (0.4%), tests_pri_-400: 24 (6.2%), check_bayes: 22 (5.7%), b_tokenize: 8 (2.1%), b_tok_get_all: 6 (1.5%), b_comp_prob: 3.3 (0.8%), b_tok_touch_all: 2.1 (0.5%), b_finish: 0.81 (0.2%), tests_pri_0: 315 (80.0%), check_dkim_signature: 0.84 (0.2%), check_dkim_adsp: 6 (1.4%), tests_pri_500: 8 (1.9%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 17/20] 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 in01.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