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 AEE85C3DA4A for ; Mon, 5 Aug 2024 17:14:51 +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=7424mhdYZpX1LXDOpo5e95Mtm6qlQilP9SrPlJKzK5U=; b=YGs4nP37jH6Nb4SV6eXNRA5YWU WUiAaGOYzboL1k85aRhIeS3YhGEbeN6oTdrYqIJ/2NjK3jgBP4FfzM/exdsXFTow/EbP0IbR0gsvt EC3nHMjGzGbnFIFU8cFP4RQYkON/HzyLAJmx4d3jp3YOlcdXjGJYYXic+IlB0Fk2qUD03TUJMXwab spQHJ8M0E3Maeoc3agJl/LXTnKz9EKBO7zyTo6zBResXTlZYoCHCNZEY8nY92KpZDs6U3+qI8Up4e Y9yPqbuM7I/XDapFioCmCpZ7y3DI9iA0DtNKPAqxyr4uJgHWS0aYH/JBkjlLP1poyBgqpcmZzlt6v wAuNUltA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb1I5-0000000GeR6-1glV; Mon, 05 Aug 2024 17:14:37 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sb1HL-0000000GeFX-0Bo0 for linux-arm-kernel@lists.infradead.org; Mon, 05 Aug 2024 17:13:52 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id ED709CE0B42; Mon, 5 Aug 2024 17:13:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A7BABC32782; Mon, 5 Aug 2024 17:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722878028; bh=cbBt27hkdYHhswR7zddV7pmhvdwW7EAG8ILuZV1nH1w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=j9+YjFaxZSYW0ZixSlvUm/Ty/OMkCZIU9jpLjS3AJqB3q3k9IBl/Vn77b+5COySEc WsMh6JRodj08EwWvXcBxQS3R/dh6B6AaDG0MNl+UTqAK0baehklkdJtzUQS8ywnenk H2c67m5GCoD5F4q8VBcEZeqnD9D/2x3OYrjDNhDBlhYdcjeNp6fiCkGU9LbukqCx7e f2ziKSZuPb6Hbr5meHSPVWKFiUjSxRizg6k2z8nmhAxuX9Uwj8TdqAPwncHY1gKVcO jJXBMBy5bQ2LC/M8Zh4aq91FxSXKi8RsnGAt+jrEfbYYAKzGXqCww7OwQW3IGEwHLp LXUfO/iOmsNfQ== Date: Mon, 5 Aug 2024 18:13:40 +0100 From: Will Deacon To: Alice Ryhl Cc: Catalin Marinas , Jamie Cunliffe , Sami Tolvanen , Nathan Chancellor , Conor Dooley , Masahiro Yamada , Nicolas Schier , Ard Biesheuvel , Marc Zyngier , Mark Rutland , Mark Brown , Nick Desaulniers , 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, Kees Cook Subject: Re: [PATCH v4 2/2] rust: support for shadow call stack sanitizer Message-ID: <20240805171340.GC10196@willie-the-truck> References: <20240729-shadow-call-stack-v4-0-2a664b082ea4@google.com> <20240729-shadow-call-stack-v4-2-2a664b082ea4@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240729-shadow-call-stack-v4-2-2a664b082ea4@google.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240805_101351_455434_0E8337D4 X-CRM114-Status: GOOD ( 31.31 ) 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 Hi Alice, Just some minor comments on this: On Mon, Jul 29, 2024 at 02:22:50PM +0000, Alice Ryhl wrote: > To use the shadow call stack sanitizer, you must pass special flags: > > * On arm64, you must pass -ffixed-x18 to your compiler. > * On riscv, you must pass --no-relax-gp to your linker. Since this patch doesn't touch riscv, I think you can just talk about arm64 in the commit message. > These requirements also apply to Rust code. When using Rust on arm64, > you must pass the -Zfixed-x18 flag to rustc, which has the same effect > as the -ffixed-x18 flag does for C code. The -Zfixed-x18 flag requires > rustc version 1.80.0 or greater. > > There is no need to pass any flags to rustc on riscv as only the linker > requires additional flags on this platform. > > On older versions of Rust, it is still possible to use shadow call stack > by passing -Ctarget-feature=+reserve-x18 instead of -Zfixed-x18. > However, this flag emits a warning during the build, so this patch does > not add support for using it. > > Currently, the compiler thinks that the aarch64-unknown-none target "Currently" will probably age badly -- can you talk about a compiler version instead (e.g. "prior to version nnn, the compiler thinks..."). > doesn't support -Zsanitizer=shadow-call-stack, so the build will fail if > you enable shadow call stack in non-dynamic mode. See [1] for the > relevant feature request. To avoid this compilation failure, Kconfig is > set up to reject such configurations. > > The `depends on` clause is placed on `config RUST` to avoid a situation > where enabling Rust silently turns off the sanitizer. Instead, turning > on the sanitizer results in Rust being disabled. We generally do not > want changes to CONFIG_RUST to result in any mitigations being changed > or turned off. > > Link: https://github.com/rust-lang/rust/issues/121972 [1] > Signed-off-by: Alice Ryhl > --- > Makefile | 1 + > arch/arm64/Makefile | 3 +++ > init/Kconfig | 2 +- > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 2b5f9f098b6f..66daca7a9b57 100644 > --- a/Makefile > +++ b/Makefile > @@ -928,6 +928,7 @@ ifdef CONFIG_SHADOW_CALL_STACK > ifndef CONFIG_DYNAMIC_SCS > CC_FLAGS_SCS := -fsanitize=shadow-call-stack > KBUILD_CFLAGS += $(CC_FLAGS_SCS) > +KBUILD_RUSTFLAGS += -Zsanitizer=shadow-call-stack > endif > export CC_FLAGS_SCS > endif > diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile > index f6bc3da1ef11..b058c4803efb 100644 > --- a/arch/arm64/Makefile > +++ b/arch/arm64/Makefile > @@ -57,9 +57,11 @@ KBUILD_AFLAGS += $(call cc-option,-mabi=lp64) > ifneq ($(CONFIG_UNWIND_TABLES),y) > KBUILD_CFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables > KBUILD_AFLAGS += -fno-asynchronous-unwind-tables -fno-unwind-tables > +KBUILD_RUSTFLAGS += -Cforce-unwind-tables=n > else > KBUILD_CFLAGS += -fasynchronous-unwind-tables > KBUILD_AFLAGS += -fasynchronous-unwind-tables > +KBUILD_RUSTFLAGS += -Cforce-unwind-tables=y -Zuse-sync-unwind=n These unwind entries aren't mentioned at all in the commit message. Please can you explain what you're doing here? I guess it's something to do with the PAC patching? Maybe this hunk would be better as a separate patch? Will