From patchwork Thu Jul 4 15:07:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Ryhl X-Patchwork-Id: 13723882 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 15964C30653 for ; Thu, 4 Jul 2024 15:09:16 +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:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To: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=SAGA5ww7PBaqsKtz9jWie7SRiEUO1154T36qXbEcKNY=; b=mMKAewCTBD88dU5CDQnfDqC2Ar pMSTyMq5NO6vHcI3+51Kq2HyVh6nlBVDNNsR0P4rTz8jnh3aYY0rVEX+8PbwUrBbOB+Yx6cyH6YVo 3O1Z+wYcSteOhoMdnmM1LdmxaCIdDIpkY+seqNlmfu37Z1WzFHB2tm1MH1FLDzw6kyqO8HQep1EWD zrbod/djSDrTCfLMO3KNSwKTuoaXwsDwyTu4on5Dk8cizF0igaQGx9klyTQcNWV0sVa3Jvy8kR0bx atC7SCuj/7MSfcfgTOF9XqRxq3pnc7nj+wq/MPG5WXWb5VlgPSLpioY7VoFsK8o7lxTPYbpqLfCXs xjejllyA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPO54-0000000DdBd-1PFg; Thu, 04 Jul 2024 15:09:06 +0000 Received: from mail-yw1-x114a.google.com ([2607:f8b0:4864:20::114a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPO4f-0000000Dd4a-3qdH for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2024 15:08:43 +0000 Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-64a5503e253so11568707b3.0 for ; Thu, 04 Jul 2024 08:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720105720; x=1720710520; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SAGA5ww7PBaqsKtz9jWie7SRiEUO1154T36qXbEcKNY=; b=jXrTp2Yf3me5cN2rngrBkhOMcttC1j0qWFtWw/C1DrymF4l3V6YLFmg42PschDy/A8 Si1tX4S17gmzbz/c9J12RYP66cIBsnFOpIJvT1t6IASHhCxqNVgW5gw0Mx+1l93z0hrY sChtqPXXfn3DnY6UOYrSlC+Cp8ykwjwS/r84v5YErrshGkNPe0J2cpLMIJ78QfzkAjBZ 8c16xgYKCPW7iifh/ARiULt3kTWYEK8zoNJ4BHVeIAOTO6oTHRXDk/nfzrvd4iFhzhpW qRkUQmJys0XK19+8epf8R4cKaj/Atcd+7I0DLmoXhPPN1d58HdRgWZymEIjTPEzKR94O hhpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720105720; x=1720710520; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SAGA5ww7PBaqsKtz9jWie7SRiEUO1154T36qXbEcKNY=; b=ZIpLMZOR8rGN2ccrOtsNxftTOs7FGAyg6vZhuyYQDjHk7XU8ZeFsszKpz79s9bwkWz QOlBmsWJS1dcPWcRaZWFurhA4Dc7PFiwrgFXMEpFKyNkK42jazFfbFZ3FttaB50qCojr 6ffgBDofmMQ/hGLkLFQwCecIe7qOad8Te5fV1McXt3T9IULHUUrkVC7IXX+rqOONExVu LgOVWy4hRO4O9vmPrQQjqFweS9CzRndhlnxJTxQMMxOjGZ82XCZoSlU5E/Jhom5vscA4 NxscMR9ZVYIcEawfIFslxO7hzwpi+PzbzGFhGrtvV1WQ9KbPHV5MCjkyNn49M8vxxNYr b7eQ== X-Forwarded-Encrypted: i=1; AJvYcCUShdHADPBuqSGQJRhQa4oUmdinG4xXZF8FCPuRs1quUrEMrkc+mrjC8pDWe6g82gjkMkHFBtcefgbduG0Y5lviLMxGMc7NqGLz9wHSdoBlrnDMgHw= X-Gm-Message-State: AOJu0YyXIo3b05U3IG2bSwG2brXD++CCCbHEbW8ixcdsUV+zVhb2P0Hp 7khqC2ulLlks/5exW9EUB5PB+DWQ3nlVET9/57jmasf6tK8bCjLZhKgSmoB5pZC+DejS7yFXR22 Yj3gl2Yh8hyUedA== X-Google-Smtp-Source: AGHT+IH9VR4RffY5ScSTYKGpVKwBEYexOCB2n8xGn6gRVku1k17axUw8NVFzJcK+jQWO+R5Xkyy9mMm5f3/pfeo= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:a05:690c:6ac1:b0:62f:1f63:ae4f with SMTP id 00721157ae682-652d52257fdmr189047b3.1.1720105719836; Thu, 04 Jul 2024 08:08:39 -0700 (PDT) Date: Thu, 04 Jul 2024 15:07:57 +0000 In-Reply-To: <20240704-shadow-call-stack-v3-0-d11c7a6ebe30@google.com> Mime-Version: 1.0 References: <20240704-shadow-call-stack-v3-0-d11c7a6ebe30@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=1257; i=aliceryhl@google.com; h=from:subject:message-id; bh=QPeVUrgaEZ8qmuC1e4Q7Ja32koHMoz2tK0lcoaVyWDQ=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBmhrrwg1l3+ZOI9jUnEe2Ion3jAzyudZf+KalrV Er782CNi0+JAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZoa68AAKCRAEWL7uWMY5 RuMYD/44sZG6ccdUiVJPsf3WNFs8QZDVkyvHrlDdZvFrnjTE+0I+ej6cAW8aEFxmQoaZqxeeXpx SDRqfb2Sz1Uj2ib1iSeVDyCwjoWh3E5+1Lm4upvweGFhYBYthF+y+CWYDs6CyGgNeZ5Dy3422dw GGz52J6La0cXE4+6QWpi2Zq3TViMm78qa+5CbpWhBVC2DBosxiS8R8cnOLRPBCPlEQHf9nQuztI K6dGHGRWsgz6rDq3i698LIG3yDdfIfJkB0cHAP6PvVi2MAFk/iA9XT9Keeuybof6jGr+s0/52UB o0WYgva8Rjn906xSBQGzKXw7MUiYKfsXHhNGUEaYr37nQpsjsIZz8OC7/gd9V+DqSuZw1PD7ygK MM7KZd4Xsog/XkFbddNNOIFhTCDBFRXT+oi+hnAHgZahBSOms2QKjLMXEkGP6HT9kkV8yeyQVm8 JJnLJPKLU7exs/BQS+F8CpwV/Yq9PCpWoPeHS0Kw7mHx3tyrRdYjY1qOFgYRXYo7TrLD1EPilIk 2qGi0OpfdvxyMVB2TerIT9qB4HmCsVUOoJ5t8JLxYQYVWHKlxpLDe915CBgx6jbkV5XWZEArDex LoxSzqQgKQeaHG5yS3FUOagePEZONfPqAFgK7i4ixwbAkDT871Ax5JVgV7phRM+l/2NeBgkZlu4 9RLIicJGiY7+IIA== X-Mailer: b4 0.13-dev-26615 Message-ID: <20240704-shadow-call-stack-v3-1-d11c7a6ebe30@google.com> Subject: [PATCH v3 1/2] rust: SHADOW_CALL_STACK is incompatible with Rust From: Alice Ryhl To: Catalin Marinas , Will Deacon , Jamie Cunliffe , Sami Tolvanen Cc: Masahiro Yamada , Nathan Chancellor , 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 , " =?utf-8?q?Bj=C3=B6rn_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, Alice Ryhl , stable@vger.kernel.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240704_080841_983237_1FDC7229 X-CRM114-Status: GOOD ( 12.49 ) 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 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 --- 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 From patchwork Thu Jul 4 15:07:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alice Ryhl X-Patchwork-Id: 13723883 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 619BEC3271E for ; Thu, 4 Jul 2024 15:09:29 +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:Content-Type:Cc:To:From: Subject:Message-ID:References:Mime-Version:In-Reply-To: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=Bz+EbBDOjmeMrGJd8QmvR0upRYw2Fmi/0lt2+1YTdQg=; b=uzCp+/c6n8FflkdAj5xOB35UT7 Bv41hhaZ8LcVCOLBip/s9/p2ZzxYoJVcDi65Dxnl8O2tYUx8ULEVBfri0Zu3T+4jBkuQ8m5sEiDrj 9hc+ZkwsRNMol2+Cq86Zf4PaFmntNSELTJLdmQg9ETZifrezKD2Dv9VhL4GyfypAptEYpDaQWC/Dl ttSxJwq7sF4YBVbfflimAioAq8wvOag0bKqDg5QKY/N9moko4KwX9qYDWSTrPw2eAmOM9qSXAkGwq 54EGUcGH8WaEC3KgNdGKS6ZjI0Cu6lB/GE8wj+RTU8EIUvawdAKvQBwqYSLjMmKzZpkehug1sJYOe cGHQxutQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPO5F-0000000DdG7-1ZgV; Thu, 04 Jul 2024 15:09:17 +0000 Received: from mail-lf1-x14a.google.com ([2a00:1450:4864:20::14a]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sPO4j-0000000Dd5I-2rWs for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2024 15:08:47 +0000 Received: by mail-lf1-x14a.google.com with SMTP id 2adb3069b0e04-52e9d04d773so807849e87.2 for ; Thu, 04 Jul 2024 08:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1720105723; x=1720710523; darn=lists.infradead.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=Bz+EbBDOjmeMrGJd8QmvR0upRYw2Fmi/0lt2+1YTdQg=; b=GFR+5kfW46FJZipWlNUO8gW/B3KIr5PtqPGsfuvNm6tL6X6zcvBYK3dZERsEIxXPgU k0LFUmdspINoiwNOxud66UlnXZaifAy7pZFqK8SfKCwHdeWo/PtthxxTWrMLtfquKEED OZdidiudXSf1ac8+gIdbDlLGNhcrscbb/LKs5PFUvTPZJ7gtuW6GHZSYjQEzx//VRLS9 6AOmyVs4G4epg5Q2XTsKTQ8oBBhI80nSMoN197qh2dgWewxNIdoRwy4db5lgrRGhhKn4 oQbHnq/j8yEkGhqvQapy3NimB9YQ1YfTmug1uV9ESIRtTaOOMyTUNUWbgoWXeRp6b7nn Ndhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720105723; x=1720710523; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Bz+EbBDOjmeMrGJd8QmvR0upRYw2Fmi/0lt2+1YTdQg=; b=gqE/PTOUydjF4bVcmV7kVHvLKs58Tb6QEM3C8FmcT0olqh+Io37HkUcFt4XLHVU7yY 8EE5pyP1BFCkvDRflAxwzhQ6l07X5K/JIYyKM28gUNQqxpb+mLe5GQ84Ba0IqAzlA8BA 1WPCV2rinbgdTUfKrA40CUBcVJZt3hT+MX7jm80wyHjJtWIVfX0uQ6LxBmGKaNJK8ZuO U+BIOF8NgOdHhfZGeEKrfPt97OsVaoFkJmo2gCFM9Hk8MlnoD+kTEq55V1oUcIs/zIg8 BrqpYRZU6tCRMBupbtZi57TOcC4i9xcIqXW1dfJxE6mmsFNvXK406B0mrYLKELt7E5O0 q5Bg== X-Forwarded-Encrypted: i=1; AJvYcCWIYmdAViRxZ0KeJyyr5sJ/qPCDNXRnDEQA2QwYYTrJ6DDWmbzBch+Jq/xzguQcm+eylUkhN1Jdsdj5iFSG7/4adbIKuWcE0fCv9Mg0s7KbPPmhAv8= X-Gm-Message-State: AOJu0YyfpKlaAK7KHBglNLgXfvmCuCuAfBIRb8B+DF8vuflJpxKlfhUo y8Wk6kaAGsjaIUt8kRv0+uHcUOQtjkaQugSXas1xDO5sV+gZP8+9sBu/IwcEPQ6pbmVzR3/Nllq rNibMsEKIFpgAsw== X-Google-Smtp-Source: AGHT+IE03aDhat/nctBL3TSUjtF7n0/BH4Iv3XWnyA2/KfN0iRZTIP1nm3dzjP2dil5/BZGhl8862qWvC2IkeAc= X-Received: from aliceryhl2.c.googlers.com ([fda3:e722:ac3:cc00:68:949d:c0a8:572]) (user=aliceryhl job=sendgmr) by 2002:ac2:51c5:0:b0:52c:7f96:81d1 with SMTP id 2adb3069b0e04-52ea063536dmr1741e87.6.1720105722612; Thu, 04 Jul 2024 08:08:42 -0700 (PDT) Date: Thu, 04 Jul 2024 15:07:58 +0000 In-Reply-To: <20240704-shadow-call-stack-v3-0-d11c7a6ebe30@google.com> Mime-Version: 1.0 References: <20240704-shadow-call-stack-v3-0-d11c7a6ebe30@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=2683; i=aliceryhl@google.com; h=from:subject:message-id; bh=JuGBj/G53huERAYmOEJ7zt/Eif/6HD+856XFNofQJEM=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBmhrrxeD87TT9nOZdZlSkM9Ug38Lq8pSNUKPjWV S8NfW1wCauJAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCZoa68QAKCRAEWL7uWMY5 RuclEACRYz+o0orQSxwv7q+/d5rq3VqoTqZslfFT+l8/uynAxKQaS04uT9n0J3p20m905uf+kbA jyxYAe8B1qxiRcLwgxRbrHbKCHdch+xHTn/Qr2mV9q3bNPwwM79X3rvjaVOVhYkRL5JtYZMUuLq Z1BsoS7Nb89E01i8mTQhua3kOSrs3sjneafcmOushtO6IJxXiznFxXssUNaHctx4rHNQIvi94Bs RsNZ950OQZjq9mPNFZ6ZPetrlDGFFcM9Fiy3o8QwzLQUsSJ+zb8FgN6bBnucaHg1EVplZQzYj/y UHd6j4p9PzDXvWho+jfoV3LVuKBFkmyB8wfGYWbAoAIgKsPef5TSHKErkmKV4Cd7MsSe6JeVE4j NR0qFvEw9zjxUG3Mt8tYEoSpG5XTFwdqd+cpZCn+cScG+F2olTofTbx+f81TS45rrQ58EsHhZyu AHDBIVcrQ5x39H5d0RZMLPOStirm749G3soSpvBZo6+zYk8lxPaRmOZwuDn+EapYreKrtLFEcKY rLsd87PNhxDelvB35f8h8er05euI9yQSbucbYlJCE2kOmqRJ/VBdNFoBRaMb+9B7/M+ppoxPTq2 OhnZJy1a3hf5nYwjnjqWSOpL1i50mUIrWLxSw+zmnVzGFQfWaqywlsFX2HbImPn9kPkvibqf+A9 7v/oXvrs1CicloQ== X-Mailer: b4 0.13-dev-26615 Message-ID: <20240704-shadow-call-stack-v3-2-d11c7a6ebe30@google.com> Subject: [PATCH v3 2/2] rust: add flags for shadow call stack sanitizer From: Alice Ryhl To: Catalin Marinas , Will Deacon , Jamie Cunliffe , Sami Tolvanen Cc: Masahiro Yamada , Nathan Chancellor , 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 , " =?utf-8?q?Bj=C3=B6rn_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, Alice Ryhl X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240704_080845_743028_FB452B65 X-CRM114-Status: GOOD ( 18.60 ) 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 As of rustc 1.80.0, the Rust compiler supports the -Zfixed-x18 flag, so we can now use Rust with the shadow call stack sanitizer. On older versions of Rust, it is possible to use shadow call stack by passing -Ctarget-feature=+reserve-x18 instead of -Zfixed-x18. However, this flag emits a warning, so this patch does not add support for that. Currently, the compiler thinks that the aarch64-unknown-none target doesn't support -Zsanitizer=shadow-call-stack, so the build will fail if you enable shadow call stack in non-dynamic mode. See [2] for the feature request to add this. Kconfig is not configured to reject this configuration because that leads to cyclic Kconfig rules. Link: https://github.com/rust-lang/rust/issues/121972 [1] Signed-off-by: Alice Ryhl --- Makefile | 1 + arch/Kconfig | 2 +- arch/arm64/Makefile | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c11a10c8e710..4ae741601a1c 100644 --- a/Makefile +++ b/Makefile @@ -945,6 +945,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/Kconfig b/arch/Kconfig index 238448a9cb71..5a6e296df5e6 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -690,7 +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 !RUST || RUSTC_VERSION >= 108000 depends on MMU help This option enables the compiler's Shadow Call Stack, which diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 3f0f35fd5bb7..bbf313ddd700 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)