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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B24A7C3DA7D for ; Tue, 3 Jan 2023 08:55:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237080AbjACIzg (ORCPT ); Tue, 3 Jan 2023 03:55:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229520AbjACIze (ORCPT ); Tue, 3 Jan 2023 03:55:34 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB6F8B7E8; Tue, 3 Jan 2023 00:55:33 -0800 (PST) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 286431515; Tue, 3 Jan 2023 00:56:15 -0800 (PST) Received: from FVFF77S0Q05N (unknown [10.57.37.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B8F2E3F663; Tue, 3 Jan 2023 00:55:28 -0800 (PST) Date: Tue, 3 Jan 2023 08:55:26 +0000 From: Mark Rutland To: Peter Zijlstra Cc: Dan Li , Masahiro Yamada , Michal Marek , Nick Desaulniers , Catalin Marinas , Will Deacon , Sami Tolvanen , Kees Cook , Nathan Chancellor , Tom Rix , "Paul E. McKenney" , Josh Poimboeuf , Frederic Weisbecker , "Eric W. Biederman" , Marco Elver , Christophe Leroy , Song Liu , Andrew Morton , Uros Bizjak , Kumar Kartikeya Dwivedi , Juergen Gross , Luis Chamberlain , Borislav Petkov , Masami Hiramatsu , Dmitry Torokhov , Aaron Tomlin , Kalesh Singh , Yuntao Wang , Changbin Du , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev Subject: Re: [RFC/RFT] CFI: Add support for gcc CFI in aarch64 Message-ID: References: <20221219061758.23321-1-ashimida.1990@gmail.com> <20221219132731.6ng4sz2nv6ujvu7i@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org On Mon, Dec 19, 2022 at 04:04:55PM +0100, Peter Zijlstra wrote: > On Mon, Dec 19, 2022 at 05:32:04AM -0800, Dan Li wrote: > > Hi Peter, > > > > On 12/19, Peter Zijlstra wrote: > > > On Sun, Dec 18, 2022 at 10:17:58PM -0800, Dan Li wrote: > > > > > > > 1. When a typeid mismatch is detected, the cfi_check_failed function > > > > will be called instead of the brk instruction. This function needs > > > > to be implemented by the compiler user. > > > > If there are user mode programs or other systems that want to use > > > > this feature, it may be more convenient to use a callback (so this > > > > compilation option is set to -fsanitize=cfi instead of kcfi). > > > > > > This is not going to be acceptible for x86_64. > > > > I'm not familiar enough with the x86_64 platform, could you please > > tell me why this is not acceptable? Is there a similar situation > > on the arm64 platform? > > Mostly because the call would be a 5 byte instruction while the trap > (UD2) is only 2 bytes. > > I suspect Argh64 has a similar problem if the to be called function is > outside the immediate range (26 bits or thereabout), in which case you > end up with a multi-instruction sequence to construct the call target or > so. Either that or a direct branc to a PLT. > A trap is always a single instruction. Indeed. I strongly prefer the BRK for the reasons I've given in my other reply, which include code size. Thanks, Mark.