Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2670705pxb; Mon, 31 Jan 2022 01:29:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJydPXKe+KTJC3oFksAY05txD3tq6b8Qu8unr6XDFZysPHh0ENiocLmM4aFN5+GMHo8GTF0H X-Received: by 2002:a17:90b:4c43:: with SMTP id np3mr33211257pjb.88.1643621363914; Mon, 31 Jan 2022 01:29:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643621363; cv=none; d=google.com; s=arc-20160816; b=dDMVuO9vdxO/SZ21uJNBfpBrRMP2j24qL68atZ8veRkr0WzNN4uxqEI4E5IKSo1Jmb WNygJe4tmtn1EQbtejaxS5FCObw0HQptns85+03MibgwjYUkSRd+ictQ84CyF7RToJ0y 4atfkvqpTpsNmOVMVknbYXt9HRZw2gN/HgiHZ7Ti0WYC+IHH9JUjxy/ljQ3KEJMzqyM2 1CTNVrPDr6mnArJNsWEUINM1wvWpi0Dw85stAfc/zkkNdOVkxQyavTqEuDXK8ys28iO6 iTbr7UmCn5PJBEHN8YzG3SuTmAJGncOf0DvRCLfwhlhyzazJ+K9tfpGYEvCi0Hu58U/k Yawg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=8ammFLQvGZyODjWsqpd1s1f5A13uP84NhZEWLvBCEGM=; b=IFJbYwY96/98JFv3qaeUc0FxYcpBe0IqY7v8IyE3ppL8HMQrHl88SM+6CMyoetcxN2 3jeWe3vfxntU35VxFnxQVD84J6FZCVApW0JvOM2mXubpAG/RCvIsN4pi5sVjdK4i0cS5 4Y62ZPS8o2ev0NE56/l9C7EJdWKZMiBZfkmqxF9jjwHgyOYTvhvs+elDxrGouredzfSo YYlyVLCvlVV5RjVRQGKFtOf6oNR8JOGQiyHNY4Dkjtkja+jkis+4lWtVOVZWUBvMgP1D XJC4FojvXagFtwjC+cC1IlGk1fGir/OTeW+UmFbamQXB6m0x6W7BlLcc32/vJWkPin6H ygYw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg5si12478593pgb.708.2022.01.31.01.29.12; Mon, 31 Jan 2022 01:29:23 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242488AbiA1Lmm (ORCPT + 99 others); Fri, 28 Jan 2022 06:42:42 -0500 Received: from mail.loongson.cn ([114.242.206.163]:40652 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S236347AbiA1Lml (ORCPT ); Fri, 28 Jan 2022 06:42:41 -0500 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxb+Kh1vNhREgFAA--.17556S7; Fri, 28 Jan 2022 19:42:28 +0800 (CST) From: Tiezhu Yang To: Baoquan He , Jonathan Corbet , Andrew Morton , Peter Zijlstra , Marco Elver Cc: kexec@lists.infradead.org, linux-doc@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/5] kfence: unset panic_on_warn before calling panic() Date: Fri, 28 Jan 2022 19:42:25 +0800 Message-Id: <1643370145-26831-6-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1643370145-26831-1-git-send-email-yangtiezhu@loongson.cn> References: <1643370145-26831-1-git-send-email-yangtiezhu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IY6I8E87Iv67 AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuY vjxUxVyxDUUUU X-CM-SenderInfo: p1dqw3xlh2x3gn0dqz5rrqw2lrqou0/ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As done in the full WARN() handler, panic_on_warn needs to be cleared before calling panic() to avoid recursive panics. Signed-off-by: Tiezhu Yang --- mm/kfence/report.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/mm/kfence/report.c b/mm/kfence/report.c index f93a7b2..9d61a23 100644 --- a/mm/kfence/report.c +++ b/mm/kfence/report.c @@ -267,8 +267,16 @@ void kfence_report_error(unsigned long address, bool is_write, struct pt_regs *r lockdep_on(); - if (panic_on_warn) + 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; panic("panic_on_warn set ...\n"); + } /* We encountered a memory safety error, taint the kernel! */ add_taint(TAINT_BAD_PAGE, LOCKDEP_STILL_OK); -- 2.1.0