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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B5A50D1812F for ; Mon, 14 Oct 2024 16:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=obfz6vImuh5gsn2aLaPV1gs91gXfXYMDiwQkl8kUJqM=; b=jFA0Nb/jXQMA/gHHa3+v3mMdXt IhjBK0JoU2zcuo34tpEeohxQZ+96wphi7rRR4neGgLcUwIYtmeBJpzctu7jOnmMFVVS1WmLE+UI7l HWx3JsUlr/c7u2EH39BfGdWmo06cQHokvYU0nKM0HoSYXf/YeiHFnuWuKPKDZMEDNm8bUTwDHFVr2 /smIetZ32w69bGc8NixABTJAyO2UsfRpYq8tr1N2c7ctP6u9IXq66hoM70GhpaBXH6ZgBkBcKw5gI MEHK5ET2+vR9nnpOVxiBK4a6dBOgTHWBSg4LTXPXvsKn5wJH1U9afgFCE0FxAlDZAYnapv/+g7Hnh jYj4H8/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0Nuh-00000005rGl-1S2q; Mon, 14 Oct 2024 16:27:19 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t0NtH-00000005quW-0qoJ for linux-arm-kernel@lists.infradead.org; Mon, 14 Oct 2024 16:25:52 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9F51E1007; Mon, 14 Oct 2024 09:26:19 -0700 (PDT) Received: from J2N7QTR9R3 (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 89B493F71E; Mon, 14 Oct 2024 09:25:48 -0700 (PDT) Date: Mon, 14 Oct 2024 17:25:45 +0100 From: Mark Rutland To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, ryabinin.a.a@gmail.com, glider@google.com, kasan-dev@googlegroups.com, Andrey Konovalov , syzbot+908886656a02769af987@syzkaller.appspotmail.com Subject: Re: [PATCH] kasan: Disable Software Tag-Based KASAN with GCC Message-ID: References: <20241014161100.18034-1-will@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20241014161100.18034-1-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241014_092551_308159_B1FA3E3C X-CRM114-Status: GOOD ( 25.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 14, 2024 at 05:11:00PM +0100, Will Deacon wrote: > Syzbot reports a KASAN failure early during boot on arm64 when building > with GCC 12.2.0 and using the Software Tag-Based KASAN mode: > > | BUG: KASAN: invalid-access in smp_build_mpidr_hash arch/arm64/kernel/setup.c:133 [inline] > | BUG: KASAN: invalid-access in setup_arch+0x984/0xd60 arch/arm64/kernel/setup.c:356 > | Write of size 4 at addr 03ff800086867e00 by task swapper/0 > | Pointer tag: [03], memory tag: [fe] > > Initial triage indicates that the report is a false positive and a > thorough investigation of the crash by Mark Rutland revealed the root > cause to be a bug in GCC: > > > When GCC is passed `-fsanitize=hwaddress` or > > `-fsanitize=kernel-hwaddress` it ignores > > `__attribute__((no_sanitize_address))`, and instruments functions > > we require are not instrumented. > > > > [...] > > > > All versions [of GCC] I tried were broken, from 11.3.0 to 14.2.0 > > inclusive. > > > > I think we have to disable KASAN_SW_TAGS with GCC until this is > > fixed > > Disable Software Tag-Based KASAN when building with GCC by making > CC_HAS_KASAN_SW_TAGS depend on !CC_IS_GCC. > > Cc: Andrey Konovalov > Suggested-by: Mark Rutland > Reported-by: syzbot+908886656a02769af987@syzkaller.appspotmail.com > Link: https://lore.kernel.org/r/000000000000f362e80620e27859@google.com > Link: https://lore.kernel.org/r/ZvFGwKfoC4yVjN_X@J2N7QTR9R3 > Link: https://bugzilla.kernel.org/show_bug.cgi?id=218854 > Signed-off-by: Will Deacon Acked-by: Mark Rutland Thanks for putting a patch together! Mark. > --- > lib/Kconfig.kasan | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > While sweeping up pending fixes and open bug reports, I noticed this one > had slipped through the cracks... > > diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan > index 98016e137b7f..233ab2096924 100644 > --- a/lib/Kconfig.kasan > +++ b/lib/Kconfig.kasan > @@ -22,8 +22,11 @@ config ARCH_DISABLE_KASAN_INLINE > config CC_HAS_KASAN_GENERIC > def_bool $(cc-option, -fsanitize=kernel-address) > > +# GCC appears to ignore no_sanitize_address when -fsanitize=kernel-hwaddress > +# is passed. See https://bugzilla.kernel.org/show_bug.cgi?id=218854 (and > +# the linked LKML thread) for more details. > config CC_HAS_KASAN_SW_TAGS > - def_bool $(cc-option, -fsanitize=kernel-hwaddress) > + def_bool !CC_IS_GCC && $(cc-option, -fsanitize=kernel-hwaddress) > > # This option is only required for software KASAN modes. > # Old GCC versions do not have proper support for no_sanitize_address. > @@ -98,7 +101,7 @@ config KASAN_SW_TAGS > help > Enables Software Tag-Based KASAN. > > - Requires GCC 11+ or Clang. > + Requires Clang. > > Supported only on arm64 CPUs and relies on Top Byte Ignore. > > -- > 2.47.0.rc1.288.g06298d1525-goog >