Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1579046pxb; Tue, 8 Feb 2022 22:59:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJypV+Ohwkogg2MRzowWmgaf6TdfoMYNlc+JbDGFsTp0D9uUsqGggNE1zjW6gHzLpHv163pa X-Received: by 2002:a17:90b:1d8d:: with SMTP id pf13mr1834733pjb.205.1644389946085; Tue, 08 Feb 2022 22:59:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644389946; cv=none; d=google.com; s=arc-20160816; b=JLydbq4kFRF5U2Mv1YhaZSe5GeMlktzVyygPvf42Zzc0IDengdVpiCv97R5xd8gaXy gcoXeVQNi0tPGN5ThrrD9RWXdnK/5NvsG4HmVWtsDToEnwDERc2t9oXrihQagyUemvc/ Gu6vMuq+pvoV8VjxpM5G7/jsO3FiyBIQlnD7etuvdwjJNQs31NwONpQf/svxUZxW9r/L 53XKiU71X7qbfS7gGcW10hiX/MkglRzvDMkFkDRlDNZ/pQsd6uM34iiebmxCYDEIVKQg ecdybMwU7TnKlJxQyiLz5Oioj6pHcOR5plfzfmEuZ2gNeb8SKKYs6hbR9lFc2WtZes4p gvJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=aozwudC/vcOos+T4XrEal3CEC5loh3pS7gEJzCAbFj4=; b=MsE0+YY9PNJMcBI7lGnN3Emrely8z9jsn49M7HrpASF2D4+aGQp+bfdAe07v31lKbx 8u/3Z0iyrjTd1SDyGRNjFjHtgg4tQ+l4we6X/wOOlHaG0oEd30uqJoReCgGM2O6cLh4m GnMCiO37X0CAdP32hprUwMi5t6gxx5u66U1x2Kr3zT9J1AjMKVQh0SrljZQjToolsid5 SDi+LXY082GNsBR0C4J+no9UV1LfMERnUtNeXEomGibBfw3pD4BNHDnOOuTfWPinqNz7 8T1hCV4k7N67QhiVSbJRRtV1RUaGv+gEW8eozoCUjkOzmMpKnedjQQg0qXWa4N68YMIM rS4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=CuYzNlzS; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id y14si13505292pll.426.2022.02.08.22.59.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 22:59:06 -0800 (PST) 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; dkim=pass header.i=@google.com header.s=20210112 header.b=CuYzNlzS; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8787EC001F5C; Tue, 8 Feb 2022 22:19:50 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358068AbiBHNih (ORCPT + 99 others); Tue, 8 Feb 2022 08:38:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349830AbiBHNig (ORCPT ); Tue, 8 Feb 2022 08:38:36 -0500 Received: from mail-yb1-xb2b.google.com (mail-yb1-xb2b.google.com [IPv6:2607:f8b0:4864:20::b2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5702CC03FECE for ; Tue, 8 Feb 2022 05:38:35 -0800 (PST) Received: by mail-yb1-xb2b.google.com with SMTP id v186so50039116ybg.1 for ; Tue, 08 Feb 2022 05:38:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aozwudC/vcOos+T4XrEal3CEC5loh3pS7gEJzCAbFj4=; b=CuYzNlzSPt8K8Zsw3zfLs5dxCxu8+1M+XWAuVWoAnmMbstSM6hUICL5HKQKvX0d83w 3mb1Lm/9oHX7KTaRSiM+AwRiqI7xM0DXk864rOLprebh9kOrGLGu/GQmApDcWwQ0ob2D fcUX6XSrIIFBHcXTTWhvlpV5WdLv79T02lz2wJhOsJtB2T21LTTn7igH6ouD0b84zivY l8wSOg+k9V/SWuzjKLfIq8RSm34RCJG79GskXIa1HlJNuosZcNzSYbtiNOpU/SnekFio wm103hivl5xIjGy4n8NJUZgu6HOs4Fq/7uEvR/1JhhIAyuhPsSK2ZCEKkk7eA4x7ylbR GmBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aozwudC/vcOos+T4XrEal3CEC5loh3pS7gEJzCAbFj4=; b=sbxMe2yECjGO9pl/ogK2yetscy7witDFSCDqcvFQftC2EumP3VacVsZPePs7L7H4Ff PWPLidysbdb4FNiFY9Ab6V+jpoJWTWlVQSiIFvughCVHAtMffZvFAq9XOMDZfoFG1Htf w98iVO1fzP4V3AkJiPVd/4EggxRaBU0P9LZjG+SYGrsEbVzshR+xZrGYdyQaLVpSJtPS UNQzM+KBsahbJz8sc/1EWT4u9VcGRiO+F+lurleLenCzJtcT7ozCtjB71wcltJ6dRJ+G h9ZRJ+jhDATKeRSTIzN70ajWNSHIzl4P2PkBWQqxdibODVFM2OwiKS0KS2ANjY8YkzbW nyUw== X-Gm-Message-State: AOAM5339vJf/ZbhhMxm3ryIgd6tYCGlDUtB2O4ppUWJoFA1KioRYGxOA VjbhbtagFyU+Cwe0s+ltGSTxKkvBhb3wLlf6wo3TeQ== X-Received: by 2002:a25:cc54:: with SMTP id l81mr4366915ybf.236.1644327514316; Tue, 08 Feb 2022 05:38:34 -0800 (PST) MIME-Version: 1.0 References: <1644324666-15947-1-git-send-email-yangtiezhu@loongson.cn> <1644324666-15947-4-git-send-email-yangtiezhu@loongson.cn> In-Reply-To: <1644324666-15947-4-git-send-email-yangtiezhu@loongson.cn> From: Marco Elver Date: Tue, 8 Feb 2022 14:38:22 +0100 Message-ID: Subject: Re: [PATCH v2 3/5] panic: unset panic_on_warn inside panic() To: Tiezhu Yang Cc: Baoquan He , Jonathan Corbet , Andrew Morton , Andrey Ryabinin , Xuefeng Li , kexec@lists.infradead.org, linux-doc@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-15.3 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=unavailable 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 Tue, 8 Feb 2022 at 13:51, Tiezhu Yang wrote: > > In the current code, the following three places need to unset > panic_on_warn before calling panic() to avoid recursive panics: > > kernel/kcsan/report.c: print_report() > kernel/sched/core.c: __schedule_bug() > mm/kfence/report.c: kfence_report_error() > > In order to avoid copy-pasting "panic_on_warn = 0" all over the > places, it is better to move it inside panic() and then remove > it from the other places. > > Signed-off-by: Tiezhu Yang Reviewed-by: Marco Elver > --- > kernel/panic.c | 20 +++++++++++--------- > 1 file changed, 11 insertions(+), 9 deletions(-) > > diff --git a/kernel/panic.c b/kernel/panic.c > index 55b50e0..95ba825 100644 > --- a/kernel/panic.c > +++ b/kernel/panic.c > @@ -185,6 +185,16 @@ void panic(const char *fmt, ...) > int old_cpu, this_cpu; > bool _crash_kexec_post_notifiers = crash_kexec_post_notifiers; > > + if (panic_on_warn) { > + /* > + * This thread may hit another WARN() in the panic path. Alas, this may actually fix another problem: doing a panic() not from a WARN(), but then hitting a WARN() along in the panic path. So "another WARN" is irrelevant, just "a WARN" would be enough to break things. > + * Resetting this prevents additional WARN() from panicking the > + * system on this thread. Other threads are blocked by the > + * panic_mutex in panic(). > + */ > + panic_on_warn = 0; > + } > + > /* > * Disable local interrupts. This will prevent panic_smp_self_stop > * from deadlocking the first cpu that invokes the panic, since > @@ -576,16 +586,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, > if (regs) > show_regs(regs); > > - if (panic_on_warn) { > - /* > - * This thread may hit another WARN() in the panic path. > - * Resetting this prevents additional WARN() from panicking the > - * system on this thread. Other threads are blocked by the > - * panic_mutex in panic(). > - */ > - panic_on_warn = 0; > + if (panic_on_warn) > panic("panic_on_warn set ...\n"); > - } > > if (!regs) > dump_stack(); > -- > 2.1.0 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/1644324666-15947-4-git-send-email-yangtiezhu%40loongson.cn.