public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Wang" <wanglikun@lixiang.com>
To: "Kees Cook" <keescook@chromium.org>
Cc: "Sami Tolvanen" <samitolvanen@google.com>,
	 "Peter Zijlstra" <peterz@infradead.org>,
	 "Aaron Tomlin" <atomlin@redhat.com>,
	 "Alexander Potapenko" <glider@google.com>,
	 "Alexander Shishkin" <alexander.shishkin@linux.intel.com>,
	 "Alexandru Elisei" <alexandru.elisei@arm.com>,
	 "Andrew Morton" <akpm@linux-foundation.org>,
	 "Anshuman Khandual" <anshuman.khandual@arm.com>,
	 "Ard Biesheuvel" <ardb@kernel.org>,
	 "Arnaldo Carvalho de Melo" <acme@kernel.org>,
	 "Arnd Bergmann" <arnd@arndb.de>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	 "Borislav Petkov" <bp@alien8.de>, "Borislav Petkov" <bp@suse.de>,
	 "Brian Gerst" <brgerst@gmail.com>,
	 "Catalin Marinas" <catalin.marinas@arm.com>,
	 "Changbin Du" <changbin.du@intel.com>,
	 "Christophe Leroy" <christophe.leroy@csgroup.eu>,
	 "Dave Hansen" <dave.hansen@linux.intel.com>,
	 "Dmitry Torokhov" <dmitry.torokhov@gmail.com>,
	 "Eric W. Biederman" <ebiederm@xmission.com>,
	 "Frederic Weisbecker" <frederic@kernel.org>,
	<gcc-patches@gcc.gnu.org>,
	 "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	 "H. Peter Anvin" <hpa@zytor.com>,
	"Ingo Molnar" <mingo@redhat.com>,  "Jiri Olsa" <jolsa@kernel.org>,
	"Josh Poimboeuf" <jpoimboe@kernel.org>,
	 "Juergen Gross" <jgross@suse.com>,
	 "Kalesh Singh" <kaleshsingh@google.com>,
	 "Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
	 "Luis Chamberlain" <mcgrof@kernel.org>,
	"Marco Elver" <elver@google.com>,
	 "Mark Brown" <broonie@kernel.org>,
	"Mark Rutland" <mark.rutland@arm.com>,
	 "Masahiro Yamada" <masahiroy@kernel.org>,
	 "Masami Hiramatsu" <mhiramat@kernel.org>,
	 "Michael Roth" <michael.roth@amd.com>,
	 "Michal Marek" <michal.lkml@markovi.net>,
	 "Miguel Ojeda" <ojeda@kernel.org>,
	"Namhyung Kim" <namhyung@kernel.org>,
	 "Nathan Chancellor" <nathan@kernel.org>,
	 "Nick Desaulniers" <ndesaulniers@google.com>,
	 "Nicolas Schier" <nicolas@fjasle.eu>,
	 "Paul E. McKenney" <paulmck@kernel.org>,
	 "Richard Sandiford" <richard.sandiford@arm.com>,
	 "Song Liu" <song@kernel.org>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	 "Tom Rix" <trix@redhat.com>, "Uros Bizjak" <ubizjak@gmail.com>,
	 "Will Deacon" <will@kernel.org>, <x86@kernel.org>,
	 "Yuntao Wang" <ytcoode@gmail.com>, "Yu Zhao" <yuzhao@google.com>,
	 "Zhen Lei" <thunder.leizhen@huawei.com>,
	<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" <ashimida.1990@gmail.com>
Subject: Re: [RFC/RFT,V2] CFI: Add support for gcc CFI in aarch64
Date: Mon, 18 Dec 2023 09:10:58 +0800	[thread overview]
Message-ID: <e12bb888-fc92-a8eb-a98c-fea6e446c844@lixiang.com> (raw)
In-Reply-To: <202312131132.639E8802B@keescook>

[-- Attachment #1: Type: text/plain, Size: 3304 bytes --]

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 <samitolvanen@google.com> wrote:
>>>> On Mon, Mar 27, 2023 at 2:30 AM Peter Zijlstra <peterz@infradead.org> 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
> 

Thanks Kees, I will first try to implement a simple interface based on 
mangle to generate cfi type id.

Likun Wang

声明:这封邮件只允许文件接收者阅读,有很高的机密性要求。禁止其他人使用、打开、复制或转发里面的任何内容。如果本邮件错误地发给了你,请联系邮件发出者并删除这个文件。机密及法律的特权并不因为误发邮件而放弃或丧失。任何提出的观点或意见只属于作者的个人见解,并不一定代表本公司。

  reply	other threads:[~2023-12-18  1:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20221219061758.23321-1-ashimida.1990@gmail.com>
2023-03-25  8:54 ` Dan Li
2023-03-27  9:30   ` Peter Zijlstra
2023-03-27 22:17     ` Sami Tolvanen
2023-04-05 11:49       ` Dan Li
2023-12-13  8:48       ` Dan Li
2023-12-13  9:01         ` Wang
2023-12-13 14:45           ` Mark Rutland
2023-12-18  1:05             ` Wang
2023-12-13 19:35           ` Kees Cook
2023-12-18  1:10             ` Wang [this message]
2023-04-05 11:48     ` Dan Li

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e12bb888-fc92-a8eb-a98c-fea6e446c844@lixiang.com \
    --to=wanglikun@lixiang.com \
    --cc=acme@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexandru.elisei@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=ardb@kernel.org \
    --cc=arnd@arndb.de \
    --cc=ashimida.1990@gmail.com \
    --cc=atomlin@redhat.com \
    --cc=boqun.feng@gmail.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=broonie@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=changbin.du@intel.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=dave.hansen@linux.intel.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=ebiederm@xmission.com \
    --cc=elver@google.com \
    --cc=frederic@kernel.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=jgross@suse.com \
    --cc=jolsa@kernel.org \
    --cc=jpoimboe@kernel.org \
    --cc=kaleshsingh@google.com \
    --cc=keescook@chromium.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=mark.rutland@arm.com \
    --cc=masahiroy@kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=memxor@gmail.com \
    --cc=mhiramat@kernel.org \
    --cc=michael.roth@amd.com \
    --cc=michal.lkml@markovi.net \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=nicolas@fjasle.eu \
    --cc=ojeda@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=peterz@infradead.org \
    --cc=richard.sandiford@arm.com \
    --cc=samitolvanen@google.com \
    --cc=song@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=thunder.leizhen@huawei.com \
    --cc=trix@redhat.com \
    --cc=ubizjak@gmail.com \
    --cc=will@kernel.org \
    --cc=x86@kernel.org \
    --cc=ytcoode@gmail.com \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).