Received: by 2002:a05:7412:bc1a:b0:d7:7d3a:4fe2 with SMTP id ki26csp310588rdb; Sat, 19 Aug 2023 02:45:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEvt+2IgS+SGSzI2eDsuj5UfC3tWy2MMA0byZV32WxBsPlKuOXfnYQZGSvlwjBOC6iTMt1M X-Received: by 2002:a05:6a20:7f8b:b0:145:3bd9:1377 with SMTP id d11-20020a056a207f8b00b001453bd91377mr2035947pzj.5.1692438325997; Sat, 19 Aug 2023 02:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692438325; cv=none; d=google.com; s=arc-20160816; b=Eh7t75ojhOE/V8woTfpaL7u24xlkoVAjYVlphneif9nodCS0+sX5juV0hWHQoY5wTk iEqpMRP7obzRedQP/EpfzPApfcvTojhtWPczX1QjZuX7GBu6pmL6EEPM20FwbeD1tX8B 03jkK1FdO7gBZhk127Tb6CAaZZw9JSqRv18lk0Wa9Jz70FzP2CgJY+BqEPvX+ZAlDBjN nVwfuZyOCmXxtfw319g4keHyLBLYqwsiEVefdEssNDVpSLWOZLyE+hptd16B+iQ1cmca MZtBKz1Zd/HWNcs1Y+YHy5jMZSTmgBAqUhu5Y+C4J/VX+Cp5wviXoXc647+HCi2VfcMe SP3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=kysyaGfNd7h77/XLkd1Qbsl5R8yFK0LqRnJqD8YhNcI=; fh=Qg7Eod8FjN06dERbE1bHl4TAMb3b3ZUVvAGinRSXYXA=; b=0O3OmxZaRbhUTwck/S2UWNkamhrI5ZZ4MYH0x7aK+qVcsmdGvMM1KgT7i4MWDuoQGG CBOl53Daxt+EoVtT5mN6acvRxTBnS32n/tlyaIZxrxTi2SnmaY+zp3m07XBbpBGlBMsk 8Zg7qp/ZmReYcmFJFWtcFahwT8JLyiEgm3MlXAqDga2Drnffl/fRUWOKRFvKNjwhgGFz mf2MLqiuLEkgqDBYG+9c0dVYIDw/aMU8RmMCkTByJS+eWKwno3xnG5xOsL5MBkReyC9R k+2oRouG5zTZXCYWSy1DzJziR0vyT+SsS7sVsL4jxcieuQ4I/SDO9w9Wjw6vVGvMVyXJ 9Duw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k6-20020aa788c6000000b00682759c6440si3330763pff.40.2023.08.19.02.45.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 19 Aug 2023 02:45:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 924E42F476; Sat, 19 Aug 2023 01:28:39 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357301AbjHRCmf (ORCPT + 99 others); Thu, 17 Aug 2023 22:42:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48046 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357290AbjHRCmB (ORCPT ); Thu, 17 Aug 2023 22:42:01 -0400 Received: from angie.orcam.me.uk (angie.orcam.me.uk [78.133.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 988DE273C; Thu, 17 Aug 2023 19:42:00 -0700 (PDT) Received: by angie.orcam.me.uk (Postfix, from userid 500) id D3D4E92009D; Fri, 18 Aug 2023 04:41:59 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by angie.orcam.me.uk (Postfix) with ESMTP id CCE1092009B; Fri, 18 Aug 2023 03:41:59 +0100 (BST) Date: Fri, 18 Aug 2023 03:41:59 +0100 (BST) From: "Maciej W. Rozycki" To: Tiezhu Yang cc: Thomas Bogendoerfer , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, loongson-kernel@lists.loongnix.cn Subject: Re: [PATCH v3 2/3] MIPS: Remove noreturn attribute for die() In-Reply-To: <1692005246-18399-3-git-send-email-yangtiezhu@loongson.cn> Message-ID: References: <1692005246-18399-1-git-send-email-yangtiezhu@loongson.cn> <1692005246-18399-3-git-send-email-yangtiezhu@loongson.cn> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 14 Aug 2023, Tiezhu Yang wrote: > If notify_die() returns NOTIFY_STOP, honor the return value from the > handler chain invocation in die() as, through a debugger, the fault > may have been fixed. It makes sense even if ignoring the event will > make the system unstable, by allowing access through a debugger it > has been compromised already anyway. So we can remove the noreturn > attribute for die() to make our port consistent with x86, arm64, > riscv and csky. I find it weird that you say that it is specifically the removal of the `noreturn' attribute that makes our port consistent with the other ones (and make it the change heading too). I don't think you need to mention the removal of `noreturn' even as you can see it in the code itself and it's a natural consequence of the change proper. How about: " MIPS: Do not kill the task in die() if notify_die() returns NOTIFY_STOP If notify_die() returns NOTIFY_STOP, honor the return value from the handler chain invocation in die() and return without killing the task as, through a debugger, the fault may have been fixed. It makes sense even if ignoring the event will make the system unstable: by allowing access through a debugger it has been compromised already anyway. It makes our port consistent with x86, arm64, riscv and csky. " then (notice the use of a colon rather than a comma changing the meaning of the sentence above)? > Commit 20c0d2d44029 ("[PATCH] i386: pass proper trap numbers to die > chain handlers") may be the earliest of similar changes. > > Link: https://lore.kernel.org/all/alpine.DEB.2.21.2308132148500.8596@angie.orcam.me.uk/ I think you meant: Link: https://lore.kernel.org/r/43DDF02E.76F0.0078.0@novell.com/ didn't you? > diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c > index 7a34674..4f5140f 100644 > --- a/arch/mips/kernel/traps.c > +++ b/arch/mips/kernel/traps.c > @@ -391,16 +391,15 @@ void show_registers(struct pt_regs *regs) > > static DEFINE_RAW_SPINLOCK(die_lock); > > -void __noreturn die(const char *str, struct pt_regs *regs) > +void die(const char *str, struct pt_regs *regs) > { > static int die_counter; > - int sig = SIGSEGV; > + int ret; > > oops_enter(); > > - if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_nr, > - SIGSEGV) == NOTIFY_STOP) > - sig = 0; > + ret = notify_die(DIE_OOPS, str, regs, 0, > + current->thread.trap_nr, SIGSEGV); > > console_verbose(); > raw_spin_lock_irq(&die_lock); > @@ -422,7 +421,8 @@ void __noreturn die(const char *str, struct pt_regs *regs) > if (regs && kexec_should_crash(current)) > crash_kexec(regs); > > - make_task_dead(sig); > + if (ret != NOTIFY_STOP) > + make_task_dead(SIGSEGV); It doesn't appear to me we should panic or execute the crash kernel if the oops is to be suppressed. Can we just do what the x86 port does, that is return if !sig after the call to `oops_exit'? Also I note that the individual ports aren't exactly consistent here with respect to each other, so maybe that's something you might want to post a combined follow-up clean-up patch series for too? Maciej