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 A0C90ECAAD5 for ; Mon, 5 Sep 2022 17:07: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=wZMd68HTDgQZqPS4tbbCHAlEom2FhnEAQFlBBHJgufY=; b=dkNivpwgnVWA29 Y963otaUZ7lgsWAh+QiUdgauLEhrH3HBuBrpBP9KhGHHrh7rUhjQWVHqwitG1NvdWrvoqc0w6Ol7m l1/NHA4cs/E3j6/BDfK114N0z29tTbidrVapeqj1HagvD3/i8MVrbpyKtDCThoTDsPUCqP1JL6s+5 AXDYsHncfh4sdZ8Ufvf0mssApH7YRjOOFo0AaP6zPQvpWamiStyhFf+UdCzChEhf89MF0mfoJ7cjD Y9ETCgpnCcftKAijDLHhg/Bbe6QGHeIE4K0FCtET1HL4mKotsWmTweFNe1jsByriyTTXL0yUCMUTt NEWS9nh1nwIznx4kkBYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVFXZ-007FAC-VH; Mon, 05 Sep 2022 17:05:48 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVD0G-004Mcr-ND for linux-arm-kernel@lists.infradead.org; Mon, 05 Sep 2022 14:23:11 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D5A4A61156; Mon, 5 Sep 2022 14:23:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD20FC433C1; Mon, 5 Sep 2022 14:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662387786; bh=LShMlhoog15vE/oaRK3aJ0ndkSUAPuXUhneXEkCgz88=; h=From:To:Cc:Subject:Date:From; b=TptVpLCgBk0GA9syHroc8ATMhcchFicMliw6lo6KvBFRjJG42+23w2YtO9BWD2tep m3l3xPNrdPGQWP10mvETVmIWtvn+qVgkHxUMkN+2xf1dZZVtQa/rxZqhom2frnp/1P cBN0psc7AJoBJ5uPdGY8bZPsSklE4iKlvnFrdVB6ztQPRBhc6xQzyoHxQwZZrfxNtU Dx4NcieV4ugbFQUUPYJywi5gMkv9/zlkqqYEQPr/Ash9rMzgYGr1kTKSsqm2NilU/M AjulQb7vk2+4Ju+4qhX1j5v29W14g6kLElJb9OMqlVbKIKVdDuRnLJrLDQz3TBLBfz pvDA0bkFzT57g== From: Mark Brown To: Will Deacon , Catalin Marinas Cc: D Scott Phillips , linux-arm-kernel@lists.infradead.org, Mark Rutland , Mark Brown Subject: [PATCH v2] arm64/bti: Disable in kernel BTI when cross section thunks are broken Date: Mon, 5 Sep 2022 15:22:55 +0100 Message-Id: <20220905142255.591990-1-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1905; i=broonie@kernel.org; h=from:subject; bh=LShMlhoog15vE/oaRK3aJ0ndkSUAPuXUhneXEkCgz88=; b=owGbwMvMwMWocq27KDak/QLjabUkhmQxNjuG4tqav2WGGZy75gmWnd3h/cz/wS2RaU4swQeyPnNP Pfu8k9GYhYGRi0FWTJFl7bOMVenhElvnP5r/CmYQKxPYFC5OAZjICx32/xHX+9ad4/n6b/W9aUcun1 m81vaG8vFCR49E/t7NAXOOzF9vXaJRY2Xt+stbZy/rsx3PDjH1vZKet0PJVldximry+wV/532p3X7j Wq6Ge/WWKFHeZX/n2GYdCgnUUnM2Ei1Ty72rGNv+UnVrwtWDR53P7nKzmCDYunK58an5grPf1atxan SmpMXIRZ1m316ayfJ3tbRYSJWP7/rAiRLVDWvc1ut6z+yYzl1axZonfLBIwaplm/7M+Sn3RE9M5Eg0 EAhIkfj8cPttn2+BZ9j2GNnkLF2hlye6V62PY/bcPOuleXmmaZ/+HO1pZ2PYFPdD+XJHifeMOQnsvN e6pN+2mtYfTZb4MOXrg+A1UR0fAQ== X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220905_072309_632678_804EE1D8 X-CRM114-Status: GOOD ( 15.37 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org GCC does not insert a `bti c` instruction at the beginning of a function when it believes that all callers reach the function through a direct branch[1]. Unfortunately the logic it uses to determine this is not sufficiently robust, for example not taking account of functions being placed in different sections which may be loaded separately, so we may still see thunks being generated to these functions. If that happens, the first instruction in the callee function will result in a Branch Target Exception due to the missing landing pad. While this has currently only been observed in the case of modules having their main code loaded sufficiently far from their init section to require thunks it could potentially happen for other cases so the safest thing is to disable BTI for the kernel when building with an affected toolchain. [1]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671 Reported-by: D Scott Phillips [Bits of the commit message are lifted from his report & workaround] Signed-off-by: Mark Brown --- v2: - Leave the check for the older GCC bug in place for documentation purposes. arch/arm64/Kconfig | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 9fb9fff08c94..1ce7685ad5de 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -1887,6 +1887,8 @@ config ARM64_BTI_KERNEL depends on CC_HAS_BRANCH_PROT_PAC_RET_BTI # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94697 depends on !CC_IS_GCC || GCC_VERSION >= 100100 + # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106671 + depends on !CC_IS_GCC # https://github.com/llvm/llvm-project/commit/a88c722e687e6780dcd6a58718350dc76fcc4cc9 depends on !CC_IS_CLANG || CLANG_VERSION >= 120000 depends on (!FUNCTION_GRAPH_TRACER || DYNAMIC_FTRACE_WITH_REGS) -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel