From patchwork Fri Mar 25 01:13:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 12791194 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 68359C433F5 for ; Fri, 25 Mar 2022 01:13:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 00A898D0034; Thu, 24 Mar 2022 21:13:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E5CC78D0005; Thu, 24 Mar 2022 21:13:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB0658D0034; Thu, 24 Mar 2022 21:13:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.27]) by kanga.kvack.org (Postfix) with ESMTP id BDE558D0005 for ; Thu, 24 Mar 2022 21:13:17 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B286E606CB for ; Fri, 25 Mar 2022 01:13:17 +0000 (UTC) X-FDA: 79281135234.14.848B2E4 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id 287BA120009 for ; Fri, 25 Mar 2022 01:13:17 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A960D618B8; Fri, 25 Mar 2022 01:13:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 09800C340EC; Fri, 25 Mar 2022 01:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1648170796; bh=FL25tss9M28fF1QRYqtI+0AFYi/7qNprC4pGvmQy5pg=; h=Date:To:From:In-Reply-To:Subject:From; b=aTN15rQ/5+0W8ljaMEb+NI1CB8ctmwS8pZXLkqubxZ59yKRkBtC7Vnr+G6vX98Z5t bxhM0kixFydAXhGS/Fphsi+m6BG0Hi08BYzDbrZgNQOxdBCwiiueZ1IheGvgvDkXxb fwD9Ea7XZeUXee4VdXfGaYnGwbodO2VrThwOjTpM= Date: Thu, 24 Mar 2022 18:13:15 -0700 To: ryabinin.a.a@gmail.com,glider@google.com,elver@google.com,dvyukov@google.com,andreyknvl@google.com,akpm@linux-foundation.org,patches@lists.linux.dev,linux-mm@kvack.org,mm-commits@vger.kernel.org,torvalds@linux-foundation.org,akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20220324180758.96b1ac7e17675d6bc474485e@linux-foundation.org> Subject: [patch 094/114] kasan: disable LOCKDEP when printing reports Message-Id: <20220325011316.09800C340EC@smtp.kernel.org> X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 287BA120009 X-Rspam-User: Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="aTN15rQ/"; dmarc=none; spf=pass (imf29.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org X-Stat-Signature: um9rp51bx1t3atxm7csbgj5umctq6txr X-HE-Tag: 1648170797-686738 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: From: Andrey Konovalov Subject: kasan: disable LOCKDEP when printing reports If LOCKDEP detects a bug while KASAN is printing a report and if panic_on_warn is set, KASAN will not be able to finish. Disable LOCKDEP while KASAN is printing a report. See https://bugzilla.kernel.org/show_bug.cgi?id=202115 for an example of the issue. Link: https://lkml.kernel.org/r/c48a2a3288200b07e1788b77365c2f02784cfeb4.1646237226.git.andreyknvl@google.com Signed-off-by: Andrey Konovalov Cc: Alexander Potapenko Cc: Andrey Ryabinin Cc: Dmitry Vyukov Cc: Marco Elver Signed-off-by: Andrew Morton --- mm/kasan/report.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/mm/kasan/report.c~kasan-disable-lockdep-when-printing-reports +++ a/mm/kasan/report.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,8 @@ static void start_report(unsigned long * disable_trace_on_warning(); /* Update status of the currently running KASAN test. */ update_kunit_status(sync); + /* Do not allow LOCKDEP mangling KASAN reports. */ + lockdep_off(); /* Make sure we don't end up in loop. */ kasan_disable_current(); spin_lock_irqsave(&report_lock, *flags); @@ -160,12 +163,13 @@ static void end_report(unsigned long *fl trace_error_report_end(ERROR_DETECTOR_KASAN, (unsigned long)addr); pr_err("==================================================================\n"); - add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); spin_unlock_irqrestore(&report_lock, *flags); if (panic_on_warn && !test_bit(KASAN_BIT_MULTI_SHOT, &kasan_flags)) panic("panic_on_warn set ...\n"); if (kasan_arg_fault == KASAN_ARG_FAULT_PANIC) panic("kasan.fault=panic set ...\n"); + add_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE); + lockdep_on(); kasan_enable_current(); }