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 B8F36C52D7B for ; Tue, 6 Aug 2024 20:29:23 +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=YNJJxbMCTacBJYMokN6YIRV7m5EBShQyXf92BOxMYb0=; b=CRByTICtBb+Ejw19N2cii1NwGJ 4R25AXP9eXISnWN8GehduPE3+gvSVCJu8WEIRpAvq6MGjbetUL0lwmFSz/u2GdOg9AqV2r0qXzMGa WqvVY3GH/Ky8kW/RU9m3qZhrqhw/Ktby9+jo8vKf/ddYhVJ7Zjq0VDh9RplIjImzkfHrufYGuujyN Ss0LsnNRPQpQCzQXE1mtGgSKnBO9bN74qeRSbFIsAbSL8DMpf3uf1kY3IE8513l1weRgUMXr2xBqP BA31FhYILRpHYl7p5Xdfulh57Kg1Pt89+4WjVrcPr+fJsy9J2H40BvO8YbSrnYkWl90R7wUAJI6vs QBDajRuA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbQnw-00000002oL2-2wi8; Tue, 06 Aug 2024 20:29:12 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbQmx-00000002nqs-31vg for linux-arm-kernel@lists.infradead.org; Tue, 06 Aug 2024 20:28:13 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-70d1a74a43bso797080b3a.1 for ; Tue, 06 Aug 2024 13:28:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1722976086; x=1723580886; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YNJJxbMCTacBJYMokN6YIRV7m5EBShQyXf92BOxMYb0=; b=nCvjnrzKhhlSxb3akCaysTYzpYkcKgQ+KUBuqynzBylQgmnyBAxmtUPbDBpLL7RVjG YaMLHV8sCcZ6+9Wkm15N/XEYizq0rj7vUkavjeVqmuooaxF3y8aGvzd5s/67X11H/DPH JMEbDLSlzmPTi5U38+Sz+lNp/tyuBO1MfviInpRaoTwkwIwyYSwVftIgG2hPL7adKiNE ajcQK+e9LB3Z05rwBtGffhZT59ENt721RxArOHBQhvVxw5vs5vxyyOqSdgmH3TwfjtP6 Vz0EoMLqX5Lg3gFgknXb1ZzVRgM59jUb6Es4d/KV88sZjivKtBG706NDX6XbDHtp7Tiv qKkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722976086; x=1723580886; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YNJJxbMCTacBJYMokN6YIRV7m5EBShQyXf92BOxMYb0=; b=EG3gHT/hzKa1FI1z0ISsK+w2AnGVt7eBBNkyrog4fgCSp9loU6zYCDOEk+bKMP3KY9 zV/v2xYaHbt8D2OmdbF+sK3VdYm66nRebBz7oWY052IkqyUO+cMtgnrh3pH2KfZFdIaZ 9bIX2ShpeLkkTm/yYp9KVnLh/15ag1eSiuCCGmorz78D4FOa1h27wtO0iuN/uaQbE6jg /dv/D7aUhGq9LG0j4Stq58/mBfzsSVPsuQWto/WEWKtN+B4rsL32B6gNr+xCKNXY5TW5 rzqSgvSLTF/trPlmwiFGxNH2gqcKteF/lFVUGxKrnMGzCjie8E2YeeRQok3Lmhlqt0/k A8GQ== X-Forwarded-Encrypted: i=1; AJvYcCV0fzxiFiRHT5g+0RC0ZN+r2mE2JQGQEZBVIoCnub3X88e6hpTUYr5vkPBRd6U3Go5Js5gqnPSK5h4+XBaKwdKHPhESao469BpdUO137OugNvI5d4I= X-Gm-Message-State: AOJu0YwUvsi1ZMBkPpPxw6hHoe0lBrUHn/XTrQ29qthZziGhvEKXSnsl tFSRFndRdsHwzoZG/Lcu00u4DaZ2LxbIl+JpLpXByCWGfIWNHtsvePG8kSHZ6w== X-Google-Smtp-Source: AGHT+IFm9uhPYUcX6BBhhu0nbe6Hn1ROfYd6y3IS8Wi4xqj74fV2681KS5TuBgKc0cmX3bLcvOgaPQ== X-Received: by 2002:a05:6a20:b910:b0:1c6:b364:dbd1 with SMTP id adf61e73a8af0-1c6b364e170mr7596007637.19.1722976085743; Tue, 06 Aug 2024 13:28:05 -0700 (PDT) Received: from google.com ([2620:0:1000:2510:6419:5b4c:3008:6065]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7b763562989sm7403878a12.34.2024.08.06.13.28.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 13:28:05 -0700 (PDT) Date: Tue, 6 Aug 2024 13:27:58 -0700 From: Sami Tolvanen To: Alice Ryhl Cc: Catalin Marinas , Will Deacon , Jamie Cunliffe , 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: <20240806202758.GA1634260@google.com> 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240806_132811_785667_148CA43D X-CRM114-Status: GOOD ( 29.74 ) 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. > > The -Zfixed-x18 flag is required to use SCS on arm64, and requires rustc > version 1.80.0 or greater. This restriction is reflected in Kconfig. > > When CONFIG_DYNAMIC_SCS is enabled, the build will be configured to > include unwind tables in the build artifacts. Dynamic SCS uses the > unwind tables at boot to find all places that need to be patched. The > -Cforce-unwind-tables=y flag ensures that unwind tables are available > for Rust code. > > In non-dynamic mode, the -Zsanitizer=shadow-call-stack flag is what > enables the SCS sanitizer. > > At the time of writing, all released rustc versions up to and including > 1.81 incorrectly think that the Rust targets aarch64-unknown-none and > riscv64-unknown-none-elf don'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. > > Note that because these configurations are rejected, this patch only > allows SCS to be used with arm64 and not on riscv. However, once [1] is > implemented, I will submit a follow-up patch that allows configurations > without UNWIND_PATCH_PAC_INTO_SCS on sufficiently new compilers. That > patch will implicitly allow SCS to be enabled on riscv, but this is okay > because unlike arm64, riscv does not need any flags for rustc beyond > -Zsanitizer=shadow-call-stack. > > It is possible to avoid the requirement of rustc 1.80.0 by using > -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 and instead requires 1.80.0 or greater. > > 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 Looks good to me, thanks! Reviewed-by: Sami Tolvanen Sami