Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp266899pxm; Wed, 2 Mar 2022 15:00:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJyF45o3pbXMTBDZGiI1ugUi9kCiP+QQ2uhF5lGlh8kQHxOPSZIO+sXSqOCnUVZshrroiY7Q X-Received: by 2002:a17:90a:cca:b0:1bd:729:5091 with SMTP id 10-20020a17090a0cca00b001bd07295091mr2120811pjt.105.1646262043443; Wed, 02 Mar 2022 15:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646262043; cv=none; d=google.com; s=arc-20160816; b=yHVWHo5mxoVuiCVyn7psQ1P1BeUqm5md1iFOh7etG0bJB9tZpHNXRWoIwgsIYs34mQ rzDIjkLtfMJ/QHmX0YCnLyS0mI2hJiSLDW87PV9Z+hdLH8AJxDZb59D9Mu5y7BYiqZY1 xJfBXDuLe624PuigNvxCj09zom0eT0J298jSzrywY64G3G4i62cIMHV7kVhVUqf8MUOU EGvkD6NIIDylcjyxmX3b0A4ePVFu2gQwXGPqGy9eiQ2mAvHkCepQPla2b4yFQBt9bBO8 LywPpJg13y7Lp0x8sFDeoc/C3AyvxY6dhyHGEGQgrEfcV7V+LsBEqMXQUI522VfBvJ3X 56qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EfvBgrtiG9LxjqkuYus7pXkmugj62NhRZroC7mYbdoA=; b=SEi/dWnca6RMmaPlBi68m5wF0qEIEugREU7w+luzs3K2Pb9hrpKZyFBSAy7vrFb4Gs Y42knEmjfGpMX5NkoFpbAJm/87Q/c910UHfLoGPZF0wZitqKm9lRVCJEaRofmHOKVdo3 ywjjwpsObl0ITplHveBv7OZ50Xkhcwhje2Zlazx+wTf3d6DEBb9q7dYdtmxc+4DpfcXO 58Y83sJc+MsYGzH4UvGiFgR8Yu+fZCOK3OTb3uAZhEArvXHzfTngxT2FRLaKhSvsw2jx 74JkhIw3BTFHtpHAFtDy5S3+h/ohsTu8P3qq40twzqtPKXrMXzodbhvatWNo54T0aM5X CXZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=THIJtJGD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r19-20020a63ec53000000b00363402e52d9si320611pgj.511.2022.03.02.15.00.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 15:00:43 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=THIJtJGD; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 88B3F129B8E; Wed, 2 Mar 2022 14:46:33 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243520AbiCBQlD (ORCPT + 99 others); Wed, 2 Mar 2022 11:41:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243299AbiCBQkt (ORCPT ); Wed, 2 Mar 2022 11:40:49 -0500 Received: from out0.migadu.com (out0.migadu.com [94.23.1.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67DA3CEA1F for ; Wed, 2 Mar 2022 08:40:05 -0800 (PST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1646239203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EfvBgrtiG9LxjqkuYus7pXkmugj62NhRZroC7mYbdoA=; b=THIJtJGDx8c6x+4JQpn2g1iQhzIDsWS/5VO7QzZGjLDo01uIBOCrChB4ZwgGPBwTPlHGev xXHLCbncZrgFyeUIjdf3mTUK10EXxvJLRLJyvp8BnnakIwuMiW8z8u0wXBHT1GzaCglHU6 pbbL0cwlGXse4K05c9u6n5xLIKgmCZI= From: andrey.konovalov@linux.dev To: Marco Elver , Alexander Potapenko Cc: Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm 22/22] kasan: disable LOCKDEP when printing reports Date: Wed, 2 Mar 2022 17:36:42 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Andrey Konovalov 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. Signed-off-by: Andrey Konovalov --- mm/kasan/report.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mm/kasan/report.c b/mm/kasan/report.c index c9bfffe931b4..199d77cce21a 100644 --- a/mm/kasan/report.c +++ b/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 *flags, bool sync) 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 *flags, void *addr) 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(); } -- 2.25.1