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 69B05ECAAD3 for ; Mon, 5 Sep 2022 16:38:55 +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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=MumspSV94PJsc0XIcKMhAMJvhQVfE5HQvCnajUeBFmU=; b=iMmO7LA5Ls2Hq0 MrBzfxlGGFSywNPQo+NeYf/DwJnCROOkvyPZhD5fFdREK3/20B3SAh9E9k9w/vOkCueLBNgAwmlKo QRdSr/2DhV91YjqG5vILq/hTONVpUJcAGD2MWm5pyQq7RHVhOkStq3QbWhRTio+U9Ff8lBpNwZ6Ae EexDN6TZHF4Gs09Nv2nMvOkSIad0537ajkge5NhC3iAmeEMxNu4zGKceoKKov/Azm0i4PvRIvys6X C6vmzENzAzUu/8JLRQ9YfoQe/fMK2NOYkkLDmVBKBWu23PB1CZoarDXwmQrHZQGRGs3eIN8p5xawy cZdBOFly7n8Kr7+QPqNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVF6Q-006xJ6-2o; Mon, 05 Sep 2022 16:37:38 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oVCX4-003beb-CQ for linux-arm-kernel@lists.infradead.org; Mon, 05 Sep 2022 13:53:14 +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 ams.source.kernel.org (Postfix) with ESMTPS id 2DC4BB80E78; Mon, 5 Sep 2022 13:52:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6C30C433D7; Mon, 5 Sep 2022 13:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662385974; bh=DIvlkJFFPqt4YkwZE3I1kTkLBfm7iAWFnV+pCaCkpoE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=GGepPbzBLL0EbPwd9ySdFjNsuVE2wXN9QYIdN4OoakRvjS9i/Q/Q0eIC5e2YzkgHG 7QFRFYL9/5npTkMUhhlfJQkMGKuFUoCXEbUcnpgL6H7eY3n7IvzE9UazWX76IJNcbb +1p4AdIuXOcFlh/7b6aJmb8lVt5+9GYVDhemNeHrpmlsoX17bCllPpjg0/IPre2u74 A+S/U51SCFkBIBqfLqxnlTlkZgqDrdi6zlMhVcKWyrreIrUATxS6gEfqQtnfnEX0xv 1iN26GM2FGcBEZOUFoFfrXOXSNSZJBM9Q9cGHz2SYBvOgH9MwUCaxf9IrQgesc5MGw JSZ9wGGtalFtg== Date: Mon, 5 Sep 2022 14:52:49 +0100 From: Will Deacon To: Mark Brown Cc: D Scott Phillips , Catalin Marinas , linux-arm-kernel@lists.infradead.org, Mark Rutland Subject: Re: [PATCH] arm64/bti: Disable in kernel BTI when cross section thunks are broken Message-ID: <20220905135249.GC27799@willie-the-truck> References: <20220902124724.19334-1-broonie@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20220902124724.19334-1-broonie@kernel.org> 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-20220905_065311_535376_668F54A4 X-CRM114-Status: GOOD ( 29.61 ) 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 On Fri, Sep 02, 2022 at 01:47:24PM +0100, Mark Brown wrote: > 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 > --- > > I'm sending this as an alternative to Scott's workaround in: > > https://lore.kernel.org/r/20220902001551.2349544-1-scott@os.amperecomputing.com > > in case people aren't comfortable with that, given the GCC bug it seems > likely that it is possible to generate some other case where there might > be issues. Thanks; I much prefer this simple fix for now, especially as the GCC bug doesn't seem to have concluded. Just one comment: > arch/arm64/Kconfig | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig > index 9fb9fff08c94..863b807681ce 100644 > --- a/arch/arm64/Kconfig > +++ b/arch/arm64/Kconfig > @@ -1885,8 +1885,8 @@ config ARM64_BTI_KERNEL > depends on ARM64_BTI > depends on ARM64_PTR_AUTH_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 Can we keep this dependency too, please? Hopefully we'll be able to add a 'GCC_VERSION >= nnnnnn' for this new issue, and then I think it's helpful to call out the issues separately so people don't think they can cherry-pick just one of the compiler fixes and it will work. Will _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel