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 166B5C30653 for ; Thu, 4 Jul 2024 16:46:20 +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=zzr5p2tYAMlXv2SuFfkibmYDBXSP3Jm40W5l06/IDm4=; b=myitoE141X6dlPM2TFEu8f8uQ8 5Ja5+BH1fL8lAed8iWMXaBn3XzGlL8y4qbOMIhG6XhQmjpaZeNOkBlbJvsEuAixjgB13OygOzJRXh VdPeMYZIuiY4+4NpBHhlElTLOmtgKjXEoHu0B+hzcx5xMPNv3LCiT/r3rTs0CxWCpjjybeb5oJWMA FZvMxH0xzNiu63uQzOvEqVo08yn4Pqpbe5JKuLprRzzbRGv6Q2ccc1d1MyllrnAtACtbt3DBRRjQo HO1o/+7ln5FmNOZ6+4oF3qOWvis/AwSIP7jBOoaeC//1sshHsnxG6c5D9LjHpYdvhq8xiyjKJc5/3 qGzv3TcA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPPav-0000000Dsvf-3eNK; Thu, 04 Jul 2024 16:46:05 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPPai-0000000Dsso-14yf for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2024 16:45:53 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 738AB62824; Thu, 4 Jul 2024 16:45:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D042C3277B; Thu, 4 Jul 2024 16:45:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720111551; bh=WheJjgM7xwoYDL2h9KMuA8Uv+Mr1sZiDhbDrO6nNij0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N/8Qk5IFaMOxhwedoQRRXvwxJ7aRBZtVyf1mVXOzpkF9wog9F4dXJ2mHn+ROUdue0 yZNdABnYecO8PZLjZ6DY5oZLAhV6bGO5W72583Hkh95G3iu9m5CGvUjcmdwH1B9pQA m2lWQUbTD5ZF0y08aUnTgpzpa0KK9CXJivtY6SJD1kpCNnzsNkSapldCHUVW3H0778 c3Tcqc4eP8/jNB0b3ihZWSRQ/plFmkAnkHRwvBc3LyDr3lEzRKLtM+495jjSccaz8b 9mqZumxHPEjoWJYugOu6AS2QcZozZ5GmiNch3Qtrwoozq6/u3YwAOH1zCZ/6dBa1Cm H0JPrHAv76+bQ== Date: Thu, 4 Jul 2024 09:45:48 -0700 From: Nathan Chancellor To: Alice Ryhl Cc: Catalin Marinas , Will Deacon , Jamie Cunliffe , Sami Tolvanen , Masahiro Yamada , Nicolas Schier , Ard Biesheuvel , Marc Zyngier , Mark Rutland , Mark Brown , Nick Desaulniers , Kees Cook , Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Valentin Obst , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, rust-for-linux@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v3 1/2] rust: SHADOW_CALL_STACK is incompatible with Rust Message-ID: <20240704164548.GB1394865@thelio-3990X> References: <20240704-shadow-call-stack-v3-0-d11c7a6ebe30@google.com> <20240704-shadow-call-stack-v3-1-d11c7a6ebe30@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240704-shadow-call-stack-v3-1-d11c7a6ebe30@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240704_094552_452768_A4DB16B9 X-CRM114-Status: GOOD ( 24.08 ) 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 Thu, Jul 04, 2024 at 03:07:57PM +0000, Alice Ryhl wrote: > When using the shadow call stack sanitizer, all code must be compiled > with the -ffixed-x18 flag, but this flag is not currently being passed > to Rust. This results in crashes that are extremely difficult to debug. > > To ensure that nobody else has to go through the same debugging session > that I had to, prevent configurations that enable both SHADOW_CALL_STACK > and RUST. > > It is rather common for people to backport 724a75ac9542 ("arm64: rust: > Enable Rust support for AArch64"), so I recommend applying this fix all > the way back to 6.1. > > Cc: # 6.1 and later > Fixes: 724a75ac9542 ("arm64: rust: Enable Rust support for AArch64") > Signed-off-by: Alice Ryhl Would it be better to move this to arch/arm64/Kconfig? diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 167e51067508..080907776db9 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -90,7 +90,7 @@ config ARM64 select ARCH_SUPPORTS_DEBUG_PAGEALLOC select ARCH_SUPPORTS_HUGETLBFS select ARCH_SUPPORTS_MEMORY_FAILURE - select ARCH_SUPPORTS_SHADOW_CALL_STACK if CC_HAVE_SHADOW_CALL_STACK + select ARCH_SUPPORTS_SHADOW_CALL_STACK if CC_HAVE_SHADOW_CALL_STACK && !RUST select ARCH_SUPPORTS_LTO_CLANG if CPU_LITTLE_ENDIAN select ARCH_SUPPORTS_LTO_CLANG_THIN select ARCH_SUPPORTS_CFI_CLANG RISC-V probably needs the same change, which further leads me to believe that this workaround should be architecture specific, as they may be fixed and enabled at different rates. diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 6b4d71aa9bed..4d89afdd385d 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -213,6 +213,7 @@ config HAVE_SHADOW_CALL_STACK def_bool $(cc-option,-fsanitize=shadow-call-stack) # https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a484e843e6eeb51f0cb7b8819e50da6d2444d769 depends on $(ld-option,--no-relax-gp) + depends on !RUST config RISCV_USE_LINKER_RELAXATION def_bool y > --- > arch/Kconfig | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/arch/Kconfig b/arch/Kconfig > index 975dd22a2dbd..238448a9cb71 100644 > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -690,6 +690,7 @@ config SHADOW_CALL_STACK > bool "Shadow Call Stack" > depends on ARCH_SUPPORTS_SHADOW_CALL_STACK > depends on DYNAMIC_FTRACE_WITH_ARGS || DYNAMIC_FTRACE_WITH_REGS || !FUNCTION_GRAPH_TRACER > + depends on !RUST > depends on MMU > help > This option enables the compiler's Shadow Call Stack, which > > -- > 2.45.2.803.g4e1b14247a-goog >