From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB644C433F5 for ; Tue, 8 Feb 2022 13:38:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 336396B0078; Tue, 8 Feb 2022 08:38:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2E6426B007B; Tue, 8 Feb 2022 08:38:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1D4136B007D; Tue, 8 Feb 2022 08:38:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 0A67B6B0078 for ; Tue, 8 Feb 2022 08:38:36 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id C819D608D5 for ; Tue, 8 Feb 2022 13:38:35 +0000 (UTC) X-FDA: 79119717390.05.6A58F4A Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) by imf23.hostedemail.com (Postfix) with ESMTP id 60644140005 for ; Tue, 8 Feb 2022 13:38:35 +0000 (UTC) Received: by mail-yb1-f175.google.com with SMTP id y6so35164734ybc.5 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=057beyvPNBn+3k8hEXLASizNYevZKAqk7HcVb23rQOTIyd0HOiTvIFC5ejPaG5iCP3 C9fe2qHkvrJ9GbhCHM7uBRHzgQGO+MHa1CdlxCFSJPwVT0bp76xdlWa9QP83Qyfpbg9J 45uZV4vxuZPiTQy4StyTUeOj8qHpXXA5Qe5r9/NhEpfaPoFTTkUX0qjzUhG1uM3XK94W rI+XZd77t8McS010jp6CdF9IgKpXVZHzTlR/D3SvoVTTxp8/EDVooR0ay8KfRnZi9Q9I v5O3+5DdDGU2TIl5SUxzcVnXGK2XbaeTaudV2g/fdSYhu2GWHXo8ifR0MmOgdEPYtchd qctQ== X-Gm-Message-State: AOAM532U5PUHx9Mdyz0vDpT1IpPH0LnvPe/xUqkM5KBStg58EwPYq6Ow Zgxg+H3qes3JBN4ODX9lics2LSg40M+oyygRaXEg6g== X-Google-Smtp-Source: ABdhPJwSy59oJ9AowR7zc65h3SA4WN4a8jjdgrW+5kfjLgRCZasyMpfVwYw0YDKZvLQR6oMK/3ezqo9+5PGKlJE+/yg= 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" Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=CuYzNlzS; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of elver@google.com designates 209.85.219.175 as permitted sender) smtp.mailfrom=elver@google.com X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 60644140005 X-Stat-Signature: juifpk8yex98yx397eju41zazpfkjb8h X-HE-Tag: 1644327515-404712 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.