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 79813C6FD1F for ; Wed, 22 Mar 2023 18:10:20 +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=J1jEi1Ub85/BriDpTNmVhmMyNoBwmf9wk458kLFAOEI=; b=tdGhjqLNWyMSFJ pXF/MsA5Fi/oMVsLmBb59/3l/6WjhbZj14urrKJybtXyN+VCjTSsdHnH74z/49Y5GJddBVwFbSWma REXKqbYayzGwP5NqIz0tocPYBjQXYLA1jVRzB4dPP/+iabtm03xS468A+2zRfvXZ6sgM0NlncOXkU hlT2oM4+S1cSohJWchc3Yhjv8Rez01XDEQEosqfdsSQHp+RRy9k2zLce8E8+W6p86GBm7kj49ith4 g0aFSk5fVcQHFRztiiWPVelSD0KWSQrr6cCZmWWMX75h4lxGH6//Gf1sAxI/tliy7gXjXv+ylSbDE Fpy/6c8hFFs+aDovoMmQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pf2tu-00GxqS-2o; Wed, 22 Mar 2023 18:09:30 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pf2tr-00Gxp1-38 for linux-arm-kernel@lists.infradead.org; Wed, 22 Mar 2023 18:09:29 +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 94778B81D85; Wed, 22 Mar 2023 18:09:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA23EC433EF; Wed, 22 Mar 2023 18:09:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1679508565; bh=rKyFWBTQcPTAVIuUKruObSLtclAXQDlxYQfje95ORrA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TyVFQc7wqlWQGlRcU0TuT1nvKcoMi/ban0h9rLhxT3EKvCQ1mhz1X5YUznVkPmJUw KLLiNmsFC0Jh52oNMVAVrUYpHH0wMP/lDF03hN0Zts6HKnD4hUZOnXjhWzuSUKBK7U //8xvM3ovlHH2+E7B/TX/ZJXjfwv5CqXJKrYAyiKVFd71wxXN6zB3SxEMCY/WvWxMD BXjKp4/WVybJiWfSydGfCuzkgjjKVD/oCgRqi0mH2heL8Nzpjxd5lB6kNCEtloJM1E wtdwUSERRJ+oSpEbk8luVT/bNNTCsTOVhakgGmCT4/uVG5YNj3bIOsLlybiiLc5apq 9bLTI8wRLSzeA== Date: Wed, 22 Mar 2023 11:09:22 -0700 From: Josh Poimboeuf To: Mark Rutland Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Jason Baron , Steven Rostedt , Ard Biesheuvel , Christophe Leroy , Paolo Bonzini , Sean Christopherson , Sami Tolvanen , Nick Desaulniers , Will McVicker , Kees Cook , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH v2 08/11] arm64/static_call: Fix static call CFI violations Message-ID: <20230322180922.htvb2zau2w7oichy@treble> References: <3d8c9e67a7e29f3bed4e44429d953e1ac9c6d5be.1679456900.git.jpoimboe@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230322_110928_173575_ADA923FD X-CRM114-Status: GOOD ( 19.03 ) 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 Wed, Mar 22, 2023 at 12:22:07PM +0000, Mark Rutland wrote: > > The problem is that the __perf_guest_state() static call does an > > indirect branch to __static_call_return0(), which isn't CFI-compliant. > > IIUC that'd be broken even with the old CFI mechanism, since commit: > > 87b940a0675e2526 ("perf/core: Use static_call to optimize perf_guest_info_callbacks") > > If so, we probably want a Fixes tag? Yeah, it should definitely get a Fixes tag. I wasn't quite sure if this bug started with the above commit or with the CFI_CLANG switch to kcfi. And then I forgot to investigate. > > +/* Generate a CFI-compliant static call NOP function */ > > +#define __ARCH_DEFINE_STATIC_CALL_CFI(name, insns) \ > > + asm(".align 4 \n" \ > > + ".word __kcfi_typeid_" name " \n" \ > > + ".globl " name " \n" \ > > + name ": \n" \ > > + "bti c \n" \ > > + insns " \n" \ > > + "ret \n" \ > > + ".type " name ", @function \n" \ > > + ".size " name ", . - " name " \n") > > + > > +#define __ARCH_DEFINE_STATIC_CALL_RET0_CFI(name) \ > > + GEN_CFI_SYM(STATIC_CALL_RET0_CFI(name)); \ > > + __ARCH_DEFINE_STATIC_CALL_CFI(STATIC_CALL_RET0_CFI_STR(name), "mov x0, xzr") > > This looks correct, but given we're generating a regular functions it's > unfortunate we can't have the compiler generate the actual code with something > like: > > #define __ARCH_DEFINE_STATIC_CALL_RET0_CFI(rettype, name, args...) \ > rettype name(args) \ > { \ > return (rettype)0; \ > } > > ... but I guess passing the rettype and args around is painful. Hm, I hadn't considered that. I'll play around with it. > Regardless, I gave this a spin atop v6.3-rc3 using LLVM 16.0.0 and CFI_CLANG, > and it does seem to work, so: > > Tested-by: Mark Rutland Thanks! -- Josh _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel