From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from va-1-14.ptr.blmpb.com (va-1-14.ptr.blmpb.com [209.127.230.14]) by sourceware.org (Postfix) with UTF8SMTPS id 2391F3858C35 for ; Mon, 18 Dec 2023 01:11:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2391F3858C35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lixiang.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lixiang.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2391F3858C35 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=209.127.230.14 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702861873; cv=none; b=mI94Q99DJPP70ha1wz9vuZgRDum32V1uVXSgZT0q8eQFgws7JAnvQnRWP3zblXhodW4gIgNFgeknxNMpRGKoiV1PDF/NgE6MXWDGLYXnSthF1QkvWHeeYUErax+BP+nu+PmJuCjamwViuS8aBHwdYAGPBk2xRItJRBBuONH3Hyo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702861873; c=relaxed/simple; bh=P5SVDfpkNnZbyNkLmZFcmQqasNXmyyxBqOc5gPXu4z8=; h=DKIM-Signature:To:Subject:Date:Mime-Version:From:Message-Id; b=FX02juhd0ErDJFxhwI4KD2+/VBUqYK7fyVTUhOV3H4X4m9JRkhqI8m5gOIbpzIbvjvF7FPr6j1cBuNqSwmiZDf4Zx+QNYxVjdqMSyyhj77+sYrLymtc+2f0jt0NPMMyCJZ3O4OS8cFnVDKoGWXnnAOOeaYbM3gA8d75vi47Jdfg= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=lixiang-com.20200927.dkim.feishu.cn; t=1702861863; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=P5SVDfpkNnZbyNkLmZFcmQqasNXmyyxBqOc5gPXu4z8=; b=1E/CzQjl6a1X3E6ejzjbW8I8L3YBphkkutdGRGMmS86ScN2CpUfpvk8zdSl8jMQEC/P39L JEhAuDRvVpL25Izllri3u2JYGrsDfRG+C0miA/+xycNRMXPXbK8+hJ/jIVRk169d/8AEC7 QIwKyQZfEl3UBVAJibLnUsDQyyOoaVdX0hukce0M3z+TzUIQDqGo8FQJU+epDsEfeG4gcP 30iKSu4QJXE4oQkrN9cUssYvbgrucQwZ/SdUE0mrvqCJltxjnysNW1oQEe9UU4UjHKu6Zg vjSlpl2DuPEUUEZqZAcE+YuM9jxYPETLiAsdmJWS/ty0fenv1sbepyyingPgDg== To: "Kees Cook" Content-Language: en-US X-Original-From: Wang X-Lms-Return-Path: Content-Transfer-Encoding: 8bit Subject: Re: [RFC/RFT,V2] CFI: Add support for gcc CFI in aarch64 Date: Mon, 18 Dec 2023 09:10:58 +0800 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" , , "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" , , "Yuntao Wang" , "Yu Zhao" , "Zhen Lei" , , , , , , , , , "Dan Li" 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> <202312131132.639E8802B@keescook> Mime-Version: 1.0 In-Reply-To: <202312131132.639E8802B@keescook> Content-Type: multipart/alternative; boundary=89227660c19de71e3e80f1af96482e3435e9a5935b1e83a1cbe38e4b22a7 Received: from [10.124.192.10] ([111.205.82.9]) by smtp.feishu.cn with ESMTPS; Mon, 18 Dec 2023 09:11:01 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.13.1 From: "Wang" Message-Id: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_50,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,HTML_MESSAGE,KAM_NUMSUBJECT,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --89227660c19de71e3e80f1af96482e3435e9a5935b1e83a1cbe38e4b22a7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 On 2023/12/14 03:35, Kees Cook wrote: > 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 w= rote: >>>> On Mon, Mar 27, 2023 at 2:30=E2=80=AFAM 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 includi= ng: >>>>>> >>>>>> 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, whi= ch >>>>> 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 C= FI. >=20 > Welcome; this is great news! :) Thanks for picking up the work. >=20 >> >> 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=EF=BC= =8Cbecause >> 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=C2=A0 let it work first on linux kernel, a= nd >> left the compatible issue to be solved later? >=20 > 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). >=20 > 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. >=20 > -Kees >=20 Thanks Kees, I will first try to implement a simple interface based on=20 mangle to generate cfi type id. Likun Wang =E5=A3=B0=E6=98=8E=EF=BC=9A=E8=BF=99=E5=B0=81=E9=82=AE=E4=BB=B6=E5=8F=AA=E5= =85=81=E8=AE=B8=E6=96=87=E4=BB=B6=E6=8E=A5=E6=94=B6=E8=80=85=E9=98=85=E8=AF= =BB=EF=BC=8C=E6=9C=89=E5=BE=88=E9=AB=98=E7=9A=84=E6=9C=BA=E5=AF=86=E6=80=A7= =E8=A6=81=E6=B1=82=E3=80=82=E7=A6=81=E6=AD=A2=E5=85=B6=E4=BB=96=E4=BA=BA=E4= =BD=BF=E7=94=A8=E3=80=81=E6=89=93=E5=BC=80=E3=80=81=E5=A4=8D=E5=88=B6=E6=88= =96=E8=BD=AC=E5=8F=91=E9=87=8C=E9=9D=A2=E7=9A=84=E4=BB=BB=E4=BD=95=E5=86=85= =E5=AE=B9=E3=80=82=E5=A6=82=E6=9E=9C=E6=9C=AC=E9=82=AE=E4=BB=B6=E9=94=99=E8= =AF=AF=E5=9C=B0=E5=8F=91=E7=BB=99=E4=BA=86=E4=BD=A0=EF=BC=8C=E8=AF=B7=E8=81= =94=E7=B3=BB=E9=82=AE=E4=BB=B6=E5=8F=91=E5=87=BA=E8=80=85=E5=B9=B6=E5=88=A0= =E9=99=A4=E8=BF=99=E4=B8=AA=E6=96=87=E4=BB=B6=E3=80=82=E6=9C=BA=E5=AF=86=E5= =8F=8A=E6=B3=95=E5=BE=8B=E7=9A=84=E7=89=B9=E6=9D=83=E5=B9=B6=E4=B8=8D=E5=9B= =A0=E4=B8=BA=E8=AF=AF=E5=8F=91=E9=82=AE=E4=BB=B6=E8=80=8C=E6=94=BE=E5=BC=83= =E6=88=96=E4=B8=A7=E5=A4=B1=E3=80=82=E4=BB=BB=E4=BD=95=E6=8F=90=E5=87=BA=E7= =9A=84=E8=A7=82=E7=82=B9=E6=88=96=E6=84=8F=E8=A7=81=E5=8F=AA=E5=B1=9E=E4=BA= =8E=E4=BD=9C=E8=80=85=E7=9A=84=E4=B8=AA=E4=BA=BA=E8=A7=81=E8=A7=A3=EF=BC=8C= =E5=B9=B6=E4=B8=8D=E4=B8=80=E5=AE=9A=E4=BB=A3=E8=A1=A8=E6=9C=AC=E5=85=AC=E5= =8F=B8=E3=80=82= --89227660c19de71e3e80f1af96482e3435e9a5935b1e83a1cbe38e4b22a7--