Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5542463rdb; Wed, 13 Dec 2023 11:35:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IEiUcR9V1V/pX1Wek1+SFaDi284Hi3MDSuQbcFXoR+hn8QcH+ZrqjmusH6a5s/KKjZZ3lEy X-Received: by 2002:a17:902:c411:b0:1d0:6ffd:e2b4 with SMTP id k17-20020a170902c41100b001d06ffde2b4mr10660619plk.78.1702496145386; Wed, 13 Dec 2023 11:35:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702496145; cv=none; d=google.com; s=arc-20160816; b=izzcAGVgMCeOY0uu/nmE26T3sLAKO462V+H0tzCemhQPuWe6kvVo9Ytc9OK2mTkoYK 2wi+GhjMNzHbSSj/w8ObB1G18Fdclrcheipw7wiEmzt1jMlNj3Brs9BstSNX68QQxlQV BZ98Uz7HTYvOKVOvOR/u55f4/7dFQvGwX57d5XBAlbKFD5PHjm3uFgM7mDvcQWxxQ6OW +P5VL9we8btFlO9W45cwi8zuvCvscpUoHfp7eibparcIsIOwnKmcTqnLhqTn7+z0NCEc 9Axe147bWxgfrTeO8Gs/U6g7HEM2qMZ8t2BdHp42lglC3t5DZqIUBMHvFuf4Dl+Mco5/ rl8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=ttEJmwOfFPg4dyyo48XQBXEPlFS3JK9/Eb3g52bvV2c=; fh=feF0Fho130WK+gR94rRAY471ECYRongWVlosDAjEG6U=; b=oaFSyGMnbg4/nf1hK9CnwYX/jX2S4UaPc/kdSYbzAQZxBp6Hr0B5Vnu0+Sc36akSOJ Lq8X7CGxjqd/9skO3d4P1m8ugUXyZ1vERs2Toddh8HKkATVmJtdeaWJYwz2CNmjlSyOY pNRq8RTC6VaCWDZqWwNqj29pQwbzxZ6qoJWpAN3/5/76ERjhPvbmN7/XDTQJXBPNNNyx irvJF0vMr2+GzP8SqdSdp6c6D6rfWs/a6fa5v7yl1J7aeFKMb/wYVwB0HLZokraW5+20 3QWfiKgxHarSayB8q8FfO68RPfLGBrzNIjcE7xu67DQYXGjwZiT091GJUAtoP4a6BAb5 /1tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HdSYZ+Rl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id t3-20020a170902bc4300b001d340ebab02si2661780plz.270.2023.12.13.11.35.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 11:35:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=HdSYZ+Rl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 208CA81B17C4; Wed, 13 Dec 2023 11:35:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442466AbjLMTfH (ORCPT + 99 others); Wed, 13 Dec 2023 14:35:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235448AbjLMTfC (ORCPT ); Wed, 13 Dec 2023 14:35:02 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07365AD for ; Wed, 13 Dec 2023 11:35:08 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1d08a924fcfso68481295ad.2 for ; Wed, 13 Dec 2023 11:35:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702496107; x=1703100907; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ttEJmwOfFPg4dyyo48XQBXEPlFS3JK9/Eb3g52bvV2c=; b=HdSYZ+Rlt1kWmT46bbXaflDm+/1pwDeZwYtfIqLV/dUewHeJQ5Qnb1SQRrNht+qSnd EMRlVkPRcdn5WZ+mPwRYrWdUwpmz7SrILISMDEFW9X5F8rmK0z3voMNUNsxR17asaa5a wTat7gA4fb4PzsekaRA7cXM4pBT/UZp3kL5Ys= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702496107; x=1703100907; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ttEJmwOfFPg4dyyo48XQBXEPlFS3JK9/Eb3g52bvV2c=; b=M9xZ7d71p2lGlGttYMaBQc9UFcsImBEHraGkZjZHqLZRWK5TzG8xgVCIVBdL5nNnnj YFnAa9nCEOEw2D3i9U4K1u/m8TJRTfv40M4BgLhCODZVz3jfLWZk7P9YZ4lDUJJ/cGxl R0TRiykn124xiR7j8JoFXCXBmnCRv1e38AF4ZKE9jqUgt9SdAip4zmPwQDIp/SmQjPSf jEvHufCZY2+OuJtbvq9hzjjTw2RmAjBJR+rG0KTRN6GtHFthvhY2neoti5jLWIsIT7us vJr3AjuHW5N6j4kF/TFMX+eI+sPZcuox6kw2WTovb0KuD253C2ejCQlfDtKDg+lrPBLN 25Kg== X-Gm-Message-State: AOJu0YyU7Gga8IX2rw7XNMHeqRsAfgDLEol7jKYFniS43yU+vdMqk8Hy QOPcPxi6N42p/7u3Uw+0u5hm3w== X-Received: by 2002:a17:902:7e84:b0:1d3:141:cb06 with SMTP id z4-20020a1709027e8400b001d30141cb06mr6392448pla.113.1702496107474; Wed, 13 Dec 2023 11:35:07 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id q20-20020a656854000000b005b7dd356f75sm8909940pgt.32.2023.12.13.11.35.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Dec 2023 11:35:06 -0800 (PST) Date: Wed, 13 Dec 2023 11:35:06 -0800 From: Kees Cook To: Wang Cc: Sami Tolvanen , Peter Zijlstra , Aaron Tomlin , Alexander Potapenko , Alexander Shishkin , Alexandru Elisei , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Arnaldo Carvalho de Melo , Arnd Bergmann , Boqun Feng , Borislav Petkov , Borislav Petkov , Brian Gerst , Catalin Marinas , Changbin Du , Christophe Leroy , Dave Hansen , Dmitry Torokhov , "Eric W. Biederman" , Frederic Weisbecker , gcc-patches@gcc.gnu.org, Greg Kroah-Hartman , "H. Peter Anvin" , Ingo Molnar , Jiri Olsa , Josh Poimboeuf , Juergen Gross , Kalesh Singh , Kumar Kartikeya Dwivedi , Luis Chamberlain , Marco Elver , Mark Brown , Mark Rutland , Masahiro Yamada , Masami Hiramatsu , Michael Roth , Michal Marek , Miguel Ojeda , Namhyung Kim , Nathan Chancellor , Nick Desaulniers , Nicolas Schier , "Paul E. McKenney" , Richard Sandiford , Song Liu , Thomas Gleixner , Tom Rix , Uros Bizjak , Will Deacon , x86@kernel.org, Yuntao Wang , Yu Zhao , Zhen Lei , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org, linux-arch@vger.kernel.org, linux-modules@vger.kernel.org, linux-perf-users@vger.kernel.org, Dan Li Subject: Re: [RFC/RFT,V2] CFI: Add support for gcc CFI in aarch64 Message-ID: <202312131132.639E8802B@keescook> References: <20221219061758.23321-1-ashimida.1990@gmail.com> <20230325085416.95191-1-ashimida.1990@gmail.com> <20230327093016.GB4253@hirez.programming.kicks-ass.net> <4a84af95-6270-6764-6a40-875ec20fc3e1@lixiang.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4a84af95-6270-6764-6a40-875ec20fc3e1@lixiang.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Wed, 13 Dec 2023 11:35:22 -0800 (PST) On Wed, Dec 13, 2023 at 05:01:07PM +0800, Wang wrote: > On 2023/12/13 16:48, Dan Li wrote: > > + Likun > > > > On Tue, 28 Mar 2023 at 06:18, Sami Tolvanen wrote: > >> On Mon, Mar 27, 2023 at 2:30 AM Peter Zijlstra wrote: > >>> On Sat, Mar 25, 2023 at 01:54:16AM -0700, Dan Li wrote: > >>> > >>>> In the compiler part[4], most of the content is the same as Sami's > >>>> implementation[3], except for some minor differences, mainly including: > >>>> > >>>> 1. The function typeid is calculated differently and it is difficult > >>>> to be consistent. > >>> This means there is an effective ABI break between the compilers, which > >>> is sad :-( Is there really nothing to be done about this? > >> I agree, this would be unfortunate, and would also be a compatibility > >> issue with rustc where there's ongoing work to support > >> clang-compatible CFI type hashes: > >> > >> https://github.com/rust-lang/rust/pull/105452 > >> > >> Sami > > > Hi Peter and Sami > > I am Dan Li's colleague, and I will take over and continue the work of CFI. Welcome; this is great news! :) Thanks for picking up the work. > > Regarding the issue of gcc cfi type id being compatible with clang, we > have analyzed and verified: > > 1. clang uses Mangling defined in Itanium C++ ABI to encode the function > prototype, and uses the encoding result as input to generate cfi type id; > 2. Currently, gcc only implements mangling for the C++ compiler, and the > function prototype coding generated by these interfaces is compatible > with clang, but gcc's c compiler does not support mangling.; > > Adding mangling to gcc's c compiler is a huge and difficult task,because > we have to refactor the mangling of C++, splitting it into basic > mangling and language specific mangling, and adding support for the c > language which requires a deep understanding of the compiler and > language processing parts. > > And for the kernel cfi, I suggest separating type compatibility from CFI > basic functions. Type compatibility is independent from CFI basic > funcitons and should be dealt with under another topic. Should we focus > on the main issus of cfi, and  let it work first on linux kernel, and > left the compatible issue to be solved later? If you mean keeping the hashes identical between Clang/LLVM and GCC, I think this is going to be a requirement due to adding Rust to the build environment (which uses the LLVM mangling and hashing). FWIW, I think the subset of type mangling needed isn't the entirely C++ language spec, so it shouldn't be hard to add this to GCC. -Kees -- Kees Cook