From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 402491D12FB; Wed, 23 Oct 2024 14:30:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729693854; cv=none; b=pxtPpg0mzcVNO+fIn7m3iX2mIB5VrT2r7EAdPy+5mTJnXgcxp8CpAdilaIcKiQZtAe1MJrgBDakM1dw36uga2jOxtdQXzlEajTpuubTt+59Xx3B6hjI7gwmuG1BujVLnRfrAluo1L5ebYsfoNSykOej1nMeUwH4ouIrL5T5VZPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729693854; c=relaxed/simple; bh=+FFOEpdmFUZbvSRH30E604flBFgN1bwvW7CQlSFTqXo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KjcdkLkjf2bjWUh14FuLsHlVWPV9XFREHjSYXSVlakiilKYGNDNEcPasLUp6NK4nzLpMQfMnm5r0MjNbDJDjg3VfQ1Q9xJpFG2WsDaNLvd39RXHj7r0blkkoIMP273aNWfhc4cD0KmroPpk9w8ZnO+0rYvjMuU+QRVA8mVExH5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j4CX1yg/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j4CX1yg/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA69AC4CEC6; Wed, 23 Oct 2024 14:30:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729693853; bh=+FFOEpdmFUZbvSRH30E604flBFgN1bwvW7CQlSFTqXo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j4CX1yg/MoLK93ypA83p5Lrp+PXp9c7+8ygykWv1aDR5RMqD2JwAyvR+ZdRvCJ+CK gTmELgttTxAkLujuralKr57qeImqaNIFnaQeOW/t45HTt6Q3lP6ICMS/D7lEqY6n0g bGO1LAV+6DSO6Ww0ITTQ+bnE0+lW4Eqq9wJ2sq/Zd4NWQt1KkQr7UjL0K6ZEldqKz9 X7J2g47l6XJL1zA0pB1MOTFfKo7a4fbcA3ucBmd7fj/nnKPJCD4wvp8AfZUXCLHnKZ Ab1tzyl/fAkm2prtHGc7WYWLWxrWsmKTojkls0g/y0/wyKgyHQd49Q+vWQM42ZAnBj MdNyyrMfu0G9w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Will Deacon , Andrey Konovalov , Mark Rutland , syzbot+908886656a02769af987@syzkaller.appspotmail.com, Sasha Levin , ryabinin.a.a@gmail.com, nathan@kernel.org, kasan-dev@googlegroups.com, llvm@lists.linux.dev Subject: [PATCH AUTOSEL 6.11 23/30] kasan: Disable Software Tag-Based KASAN with GCC Date: Wed, 23 Oct 2024 10:29:48 -0400 Message-ID: <20241023143012.2980728-23-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241023143012.2980728-1-sashal@kernel.org> References: <20241023143012.2980728-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.11.5 Content-Transfer-Encoding: 8bit From: Will Deacon [ Upstream commit 7aed6a2c51ffc97a126e0ea0c270fab7af97ae18 ] 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 Reviewed-by: Andrey Konovalov Acked-by: Mark Rutland Link: https://lore.kernel.org/r/20241014161100.18034-1-will@kernel.org Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- lib/Kconfig.kasan | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Kconfig.kasan b/lib/Kconfig.kasan index 98016e137b7f0..233ab20969242 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.43.0