From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E48D963B9 for ; Wed, 13 Dec 2023 19:35:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kDXhnqbL" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-286d6c95b8cso7184026a91.0 for ; Wed, 13 Dec 2023 11:35:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702496107; x=1703100907; darn=lists.linux.dev; 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=kDXhnqbL7tvYolrjj+Po4Xyb/jr5Lxx2QTyWKEj0g6+IgF1Z7kr9Eqw+5Bid8h6W// G4QhakwwedGLnnV2ZRmUTG7mbM9wHDhJHkFJUM55C6q510O3CiS3VqhjChHD4aX5/xiZ bUxqWLMvrYa2J1yM8hBMbmelM7rCy46YYdS9M= 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=HNYqgCts8iVFS67uvBWYDuZmv2k+QoYrlHcNnIODK/VxDL1P9VMskcmXkcrsaBTbu1 I2CkH15AFwcTiKQH8p8x8zz3rqO5w5Gfee5jdglBaYGxPXIHnS1Cpgr9UhAwfnN9nvN5 iRpHPTKhpUmtD4nZ5R9i3IjY8OimN9toRLcgN2XgCTEvKFFVruyzhqh8OdF8fV0C9Sla jj96R+b80aY9JyKiBAegikSRbpk5XdeZH4Osg5IzaSzOBGp55NINotZkEp+IaiE0zfSF +VIem4MGWwAwv0K1CxyMAYHKBGnPFtrnXbhJtPVCYmvG6M5vBGTuSRFnW6TvzLpfyyvj LOEg== X-Gm-Message-State: AOJu0YyQC5xQe2gZ5cgtg5w+ujMPyOzjuDxl2n07BI3ZWs2ewsjk0kI/ Q9mUEewfMIs/PhBoJvpdFz4dKw== X-Google-Smtp-Source: AGHT+IFC5O0ogGHSFN9U4m/5EgPgHuUXB72Ex5/NV/wuzLf+pctjLmlVG1zZQc96G2B2P4iPB/5lmA== X-Received: by 2002:a17:90a:6d88:b0:286:6cc1:3f17 with SMTP id a8-20020a17090a6d8800b002866cc13f17mr7490686pjk.78.1702496107255; 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 e16-20020a17090301d000b001d337dcc5afsm3718083plh.30.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> Precedence: bulk X-Mailing-List: llvm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: 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> 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