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 56843C3DA4A for ; Tue, 20 Aug 2024 14:36:15 +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=2Gpt6nSeH9BKzlXoDXkYzWrHjlHuQ7MODYSG1O//fRY=; b=lZ83+HSOZhhap/ElIvgfUuzca6 Y0MedHByYfKOvCO1G2zCGmWpo9mL3dNayZosNnkzU3NqS3eDI8pJf1nVUltEMK6iHp2yq2HccZu6T hgUAVpaFfU6E7lHGSKL12vMjEuCueH53wVcbe1NX4a/Q8rW1wOexX52ygTkO6I5PjbJYPCtmX1iFo zagyJRowZiZs9sMd2tXyDm+5vSDuE4SpEXK7iLy+ubmnO/i4W9D5/L3OXBLUSWlNj/8gDvhNd91AH bWepAqrIzaR89Wu75b+/3i5371p2vda5ELLuklG/KCJrgKfIPKJS7mvlyw3xkk5FfPR3cosWOqiyE nkqJFljw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPxu-00000005ZtY-1EXK; Tue, 20 Aug 2024 14:36:06 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPx3-00000005Zgt-2E1a for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:35:15 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E53EC60C87; Tue, 20 Aug 2024 14:35:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E152BC4AF17; Tue, 20 Aug 2024 14:35:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724164512; bh=r5UcAyWfcjLB0PGZ0XNrk1RX83pspyrEnY6LgqT8Dx4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qg+7baI9EQhBFuxIyiOJ/ikRP9AiBmAKZad91cEPtSXOohqzvBbdl8OXYLPJO2cY7 LoqitX+EZMRNKqWciz4Eia3c1cCMtibWWQEF1egcwQV8EJ/9y/MDsb6KNBXEKNvPbw ZFDVRoBeAN1AGsVmdeG5LLFN2nE7XI7jU+ltAPUGHeXSgvE94/o8WRU7pnyljllNa6 e1fB9EWgNbffKjreANu34SDkkLWIhlRBXaNEyThRqeDKNUlW7PqGXvNsrCI8K/3iu2 7JfoSCBsJjzta2V0pmHNs8KjDwf70GmduHkpHjfv7MPgbfmCx/nlZojA5ZMPZ7I4lR /4XOYBgr0cTRQ== Date: Tue, 20 Aug 2024 15:35:04 +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 v5] rust: support for shadow call stack sanitizer Message-ID: <20240820143503.GD28338@willie-the-truck> References: <20240806-shadow-call-stack-v5-1-26dccb829154@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240806-shadow-call-stack-v5-1-26dccb829154@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-20240820_073513_683308_4FC5D0A4 X-CRM114-Status: GOOD ( 21.30 ) 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 Tue, Aug 06, 2024 at 10:01:44AM +0000, Alice Ryhl wrote: > This patch adds all of the flags that are needed to support the shadow > call stack (SCS) sanitizer with Rust, and updates Kconfig to allow > configurations that work. Minor nit, but some folks have allergic reactions to "This patch". See: https://docs.kernel.org/process/submitting-patches.html#describe-your-changes I think the commit message is much better now, though, so thank you for adding so much more detail for v5. If you end up respinning anyway, you could move this all to the imperative. > Makefile | 1 + > arch/arm64/Makefile | 3 +++ > init/Kconfig | 2 +- > 3 files changed, 5 insertions(+), 1 deletion(-) > > diff --git a/Makefile b/Makefile > index 44c02a6f60a1..eb01a26d8354 100644 > --- a/Makefile > +++ b/Makefile > @@ -927,6 +927,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 > endif > > ifeq ($(CONFIG_STACKPROTECTOR_PER_TASK),y) > @@ -114,6 +116,7 @@ endif > > ifeq ($(CONFIG_SHADOW_CALL_STACK), y) > KBUILD_CFLAGS += -ffixed-x18 > +KBUILD_RUSTFLAGS += -Zfixed-x18 > endif > > ifeq ($(CONFIG_CPU_BIG_ENDIAN), y) > diff --git a/init/Kconfig b/init/Kconfig > index fe76c5d0a72e..d857f6f90885 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -1909,7 +1909,7 @@ config RUST > depends on !MODVERSIONS > depends on !GCC_PLUGINS > depends on !RANDSTRUCT > - depends on !SHADOW_CALL_STACK > + depends on !SHADOW_CALL_STACK || RUSTC_VERSION >= 108000 && UNWIND_PATCH_PAC_INTO_SCS Sorry, I didn't spot this in v4, but since UNWIND_PATCH_PAC_INTO_SCS is specific to arm64 and the only other architecture selecting ARCH_SUPPORTS_SHADOW_CALL_STACK is riscv, I can't help but feel it would be cleaner to move this logic into the arch code selecting HAVE_RUST. That is, it's up to the architecture to make sure that it has whatever it needs for SCS to work with Rust if it claims to support Rust. What do you think? Will