Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp473855pxv; Thu, 24 Jun 2021 12:06:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwA2dLS1j7xz/NEBEfsvo/X+dTINx97ugZH+iKmDE41kxS2WlziMaIMNULdF+/CPLZCCWz5 X-Received: by 2002:a5d:94ce:: with SMTP id y14mr5540150ior.67.1624561567626; Thu, 24 Jun 2021 12:06:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624561567; cv=none; d=google.com; s=arc-20160816; b=rDvXRhgpPca8iRcatK5aMXib1unR68D01wgNCkMEJjY4M0ExPQKolmpjV27aeTipJK xEX4uNreQetviYG8OOapz6GLySxHqBL49aesz+d1srt60b2Bo0dhtpAxucdnFBmtbFtG EvOuxgU4sMkfkssy2q3QGB3iBhtv31zkSe/3IjKu7JQZv+0/th1u69aQslcGqqmaoCj7 Eis8MgclfW07zp2fQ+qlzCrbUdlWXzqKG1doJPt+551q720ygtWpEfYbxYzs9TwIFnJU OMSq1m1hisTZ0mhgLzO/K31nkH4QoP6X2XmqoG74rbg0Y8WXz16x52H0QXBQ8M2nm3qX zISw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=NQMrkDbzI/yhFERXG3et3WTZ2avT0L0SQodso5h3Hn4=; b=YtvCA1ayrdIydFUAKmDCSmc06NbmhJVBCfY9UBONi16JfgF2oW1Wu3ncI9/X4ZuZXt ekQgynKtWh3FjDrva3t0d460YLjLL2GdKjXOCmQMIRBl8M/JHQ9BGpqWwNxzhd7ccW2S ij6l0ZAcsjKDx74BGsBNssdAVXz3fbG3dUzc+8opt5CfnQUnDd49Kk2hEAOKMjl/MVfz LjkJxL2YMJAIYhRv5G0rwBZtkIE0+ahdoz5kSGCBSi2ypJZ9cNKeVhiL2cLj5JzQYpPu HgBzjk3Lznwpc3qD7om6KWaRhCtQhylmZjrj51CUSR2dKC3HteIyZyJ/M90UD9pWdVKa 40bQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x5si3203711jas.126.2021.06.24.12.05.55; Thu, 24 Jun 2021 12:06:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232729AbhFXTF6 (ORCPT + 99 others); Thu, 24 Jun 2021 15:05:58 -0400 Received: from out02.mta.xmission.com ([166.70.13.232]:56404 "EHLO out02.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbhFXTFy (ORCPT ); Thu, 24 Jun 2021 15:05:54 -0400 Received: from in02.mta.xmission.com ([166.70.13.52]) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lwUdS-00GQKH-Ps; Thu, 24 Jun 2021 13:03:34 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95]:47224 helo=email.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lwUdR-003Hft-BL; Thu, 24 Jun 2021 13:03:34 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Linus Torvalds Cc: Al Viro , Michael Schmitz , linux-arch , Jens Axboe , Oleg Nesterov , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook References: <87sg1lwhvm.fsf@disp2133> <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> <924ec53c-2fd9-2e1c-bbb1-3fda49809be4@gmail.com> <87eed4v2dc.fsf@disp2133> <5929e116-fa61-b211-342a-c706dcb834ca@gmail.com> <87fsxjorgs.fsf@disp2133> <87a6njf0ia.fsf@disp2133> <87tulpbp19.fsf@disp2133> <87zgvgabw1.fsf@disp2133> <875yy3850g.fsf_-_@disp2133> Date: Thu, 24 Jun 2021 14:03:25 -0500 In-Reply-To: <875yy3850g.fsf_-_@disp2133> (Eric W. Biederman's message of "Thu, 24 Jun 2021 13:57:35 -0500") Message-ID: <87pmwb5blu.fsf_-_@disp2133> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1lwUdR-003Hft-BL;;;mid=<87pmwb5blu.fsf_-_@disp2133>;;;hst=in02.mta.xmission.com;;;ip=68.227.160.95;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX1+ubskzIAw9Nf7jzRrS5tUdPBJdmYtDWnM= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on sa06.xmission.com X-Spam-Level: ** X-Spam-Status: No, score=2.0 required=8.0 tests=ALL_TRUSTED,BAYES_50, DCC_CHECK_NEGATIVE,T_TooManySym_01,XMNoVowels,XMSubLong autolearn=disabled version=3.4.2 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * 1.5 XMNoVowels Alpha-numberic number with no vowels * 0.7 XMSubLong Long Subject * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: **;Linus Torvalds X-Spam-Relay-Country: X-Spam-Timing: total 859 ms - load_scoreonly_sql: 0.11 (0.0%), signal_user_changed: 12 (1.4%), b_tie_ro: 10 (1.2%), parse: 1.65 (0.2%), extract_message_metadata: 19 (2.2%), get_uri_detail_list: 2.5 (0.3%), tests_pri_-1000: 24 (2.8%), tests_pri_-950: 3.0 (0.4%), tests_pri_-900: 1.69 (0.2%), tests_pri_-90: 311 (36.3%), check_bayes: 309 (36.0%), b_tokenize: 23 (2.7%), b_tok_get_all: 41 (4.8%), b_comp_prob: 2.5 (0.3%), b_tok_touch_all: 238 (27.7%), b_finish: 1.15 (0.1%), tests_pri_0: 462 (53.8%), check_dkim_signature: 0.82 (0.1%), check_dkim_adsp: 3.4 (0.4%), poll_dns_idle: 0.81 (0.1%), tests_pri_10: 3.8 (0.4%), tests_pri_500: 15 (1.7%), rewrite_mail: 0.00 (0.0%) Subject: [PATCH 8/9] signal/task_exit: Use start_task_exit in place of do_exit X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reuse start_task_exit_locked to implement start_task_exit. Simplify the exit logic by having all exits go through get_signal. This simplifies the analysis of syncrhonization during exit and gurantees a full set of registers will be available for ptrace to examine at PTRACE_EVENT_EXIT. Signed-off-by: "Eric W. Biederman" --- include/linux/sched/signal.h | 1 + kernel/exit.c | 4 +++- kernel/seccomp.c | 2 +- kernel/signal.c | 12 ++++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h index a958381ba4a9..3f4e69c019b7 100644 --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -430,6 +430,7 @@ static inline void ptrace_signal_wake_up(struct task_struct *t, bool resume) void start_group_exit(int exit_code); void start_task_exit_locked(struct task_struct *task, int exit_code); +void start_task_exit(int exit_code); void task_join_group_stop(struct task_struct *task); diff --git a/kernel/exit.c b/kernel/exit.c index 635f434122b7..51e0c82b3f7d 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -889,7 +889,9 @@ EXPORT_SYMBOL(complete_and_exit); SYSCALL_DEFINE1(exit, int, error_code) { - do_exit((error_code&0xff)<<8); + start_task_exit((error_code&0xff)<<8); + /* get_signal will call do_exit */ + return 0; } diff --git a/kernel/seccomp.c b/kernel/seccomp.c index b1c06fd1b205..e0c4c123a8bf 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -1248,7 +1248,7 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd, force_sig_seccomp(this_syscall, data, true); } else { if (action == SECCOMP_RET_KILL_THREAD) - do_exit(SIGSYS); + start_task_exit(SIGSYS); else start_group_exit(SIGSYS); } diff --git a/kernel/signal.c b/kernel/signal.c index afbc001220dd..63fda9b6bbf9 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -1424,6 +1424,18 @@ void start_task_exit_locked(struct task_struct *task, int exit_code) } } +void start_task_exit(int exit_code) +{ + struct task_struct *task = current; + if (!fatal_signal_pending(task)) { + struct sighand_struct *const sighand = task->sighand; + spin_lock_irq(&sighand->siglock); + if (!fatal_signal_pending(current)) + start_task_exit_locked(task, exit_code); + spin_unlock_irq(&sighand->siglock); + } +} + struct sighand_struct *__lock_task_sighand(struct task_struct *tsk, unsigned long *flags) { -- 2.20.1