From patchwork Tue Jan 23 13:30:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 13527457 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 757EDC47DDB for ; Tue, 23 Jan 2024 13:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=9hQHbMRCeZIlbGSYcatgj2LMOMO3pVBCE0iRoviKzDM=; b=TT4PIlhPh7DYuJ6DjcFyh5UBjv s4JJjv5jZYbS1Kpx0Sc/nScS/ExVndKOrLU+7IUEmZVdutXLoGgr+40sC0f7+85KTYiJbRK4okUlM zvKRC6tRAfZQd7ACgFlkrFmn3AT/RkfgnYdREuwyzEG2vvTC/f3A52CBWV5ama4BEgNBMJMFbrZrM ld5QnEe+O8PkRxrsoVitIhDPPzybxC45wUS83D4TsdU1a8LuBALDdp38ZJmYDhmh+0ERi17SFxLpa 4YCcWTweYBc4STqtwWBqVucbhENeBURrRjEN4G04xYu/Y/7rTaDtN7/uH+3+K+IEnzEhyPR5hNTAg +Fue21Eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rSGrx-00Gd05-0R; Tue, 23 Jan 2024 13:31:13 +0000 Received: from mail-wr1-x44a.google.com ([2a00:1450:4864:20::44a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rSGrr-00Gcug-1L for linux-arm-kernel@lists.infradead.org; Tue, 23 Jan 2024 13:31:11 +0000 Received: by mail-wr1-x44a.google.com with SMTP id ffacd0b85a97d-3392814b911so1247728f8f.1 for ; Tue, 23 Jan 2024 05:31:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1706016664; x=1706621464; 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=9D0l23Qj427yQvrYU4PbANIYXPXIkr9lqLZDHbhwxbs=; b=Xe9oE/ytuxbmvUA1+cF0DUevikLZlZLlUjIiK8XzMIsaorgLxQYXbLNTdNp+6B//Kc I7AnS5wXAiEAKdbTrYaJJWjHATY91/q24cB2cok7ofpual8Y4c/hpZyhfVs6B2QUbZJw z/sXHcsGwBo4/NWNUxB/gt+/QxksbTbAsNXKI7+lNRugWzIZVBpaxI6gobFhOY5CE76/ Il4CYhBZlr0hdmzJGbJ6NQ4GwgGbQmEltOrBBNKP+ICGCjnm5LrKOr+drXUZPBbEjwug WlmtGpcBlf/zD7yZ7eDtJIZlLdxyLcFra71uiTQOaTqAlgfFMoUdXNHIaXEooG3jPmUJ dlZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706016664; x=1706621464; 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=9D0l23Qj427yQvrYU4PbANIYXPXIkr9lqLZDHbhwxbs=; b=MB6BOEykztwMRncaLAZ3fTBelsrF+onALP6gmLEMlh1h32VQGOa86CtydCGKobpikL MUzB99lQDvurPsVCKg7X7bHwKTmH8pYm1LOsuUzfn4XuovFrQl9Curi2bcryfszWnZjf 68bIEvR5rndpSYAXohXBXoRU4J3z46Y3R83bFjfY9y2IdAoEcdb45b5NO3epQFIXZB3e KA6hRI3Hsw6sOarAo1wk/EeuzPGKZlhaGrYsofSino0rm0Ffo297LcdNngdTiUOp6ah4 O+jf/FOnXBnuY30ODaxvGbIbj313h3eSdvZkP7MyBet/h7z/fU7cgIUYjc3yZUtc0o+v OIFA== X-Gm-Message-State: AOJu0Ywc7fNECS+MZsbE7SslTaM1SUitbGv32g5+aZ5/xUzk/p9dNqqS Y9RzfV5GEAlZLKfxQHxdmuw75sYBZzkK+VS2gxTZ7HsNlprThYCEmyrI/0g+oE3/sMPcTPlFUnx Iug+E7hwpb87UZ9WR68Tol0j2c/3ur/ihkmbyzqw9qZuHSPieJtvO3E8k0Sot9uSKDbf9FFNFVR B5s90OVrP2JFlQHLXF/l2bpLagsaTke/DPaReVPfcc X-Google-Smtp-Source: AGHT+IGY+UP8xGCMCpjB3xwhxIOh3zuUhcYlYv/Q4bPVtiHkYB9sCAGfFaI4QY/7a0kOIER/xaxJPcjc X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:28:9cb1:c0a8:118a]) (user=ardb job=sendgmr) by 2002:a5d:5183:0:b0:337:be13:25e7 with SMTP id k3-20020a5d5183000000b00337be1325e7mr30309wrv.6.1706016664244; Tue, 23 Jan 2024 05:31:04 -0800 (PST) Date: Tue, 23 Jan 2024 14:30:54 +0100 In-Reply-To: <20240123133052.1417449-4-ardb+git@google.com> Mime-Version: 1.0 References: <20240123133052.1417449-4-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1709; i=ardb@kernel.org; h=from:subject; bh=pMxTffXhzslc34KCuN+3KOaFPd1UOVR2q/gPI+g/Nno=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIXX9/r65/n0Wp9hnyp//UlnVOL/A84Uwy708Q579x3+2s jBWt/3pKGVhEONgkBVTZBGY/ffdztMTpWqdZ8nCzGFlAhnCwMUpABOJYmT4Z8nRKjg1duU2phs5 jcm3rzerXDovn7qqNkqBUay4ebr1QkaGmf/31RmsY5dTmvSJZ8Kzx5+s/Y+a+BmuW6Do9v+l/Ks sTgA= X-Mailer: git-send-email 2.43.0.429.g432eaa2c6b-goog Message-ID: <20240123133052.1417449-5-ardb+git@google.com> Subject: [PATCH 1/2] arm64: Revert "scs: Work around full LTO issue with dynamic SCS" From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Cc: will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, Ard Biesheuvel , Sami Tolvanen , Kees Cook X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240123_053107_462609_FCB4FDAF X-CRM114-Status: GOOD ( 13.26 ) 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 From: Ard Biesheuvel This reverts commit 8c5a19cb17a71e ("arm64: scs: Work around full LTO issue with dynamic SCS"), which did not quite fix the issue as intended. Apparently, -fno-unwind-tables is ignored for the final full LTO link when it is set on any of the objects, resulting in an early boot crash due to the SCS patching code patching itself, and attempting to pop the return address from the shadow stack while the associated push was still a PACIASP instruction when it executed. Reported-by: Sami Tolvanen Signed-off-by: Ard Biesheuvel --- arch/arm64/kernel/Makefile | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index e5d03a7039b4..d95b3d6b471a 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -73,13 +73,7 @@ obj-$(CONFIG_ARM64_MTE) += mte.o obj-y += vdso-wrap.o obj-$(CONFIG_COMPAT_VDSO) += vdso32-wrap.o obj-$(CONFIG_UNWIND_PATCH_PAC_INTO_SCS) += patch-scs.o - -# We need to prevent the SCS patching code from patching itself. Using -# -mbranch-protection=none here to avoid the patchable PAC opcodes from being -# generated triggers an issue with full LTO on Clang, which stops emitting PAC -# instructions altogether. So instead, omit the unwind tables used by the -# patching code, so it will not be able to locate its own PAC instructions. -CFLAGS_patch-scs.o += -fno-asynchronous-unwind-tables -fno-unwind-tables +CFLAGS_patch-scs.o += -mbranch-protection=none # Force dependency (vdso*-wrap.S includes vdso.so through incbin) $(obj)/vdso-wrap.o: $(obj)/vdso/vdso.so