Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp956264rwb; Mon, 26 Sep 2022 07:56:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Wl+CFe8N50Krc9+mTewiN42Vj5fV7OoEmi45iNfZlEml0xpp+ldRfn4DnbyonPbqMGR4O X-Received: by 2002:a17:902:7294:b0:178:a2be:ac18 with SMTP id d20-20020a170902729400b00178a2beac18mr22670232pll.93.1664204173750; Mon, 26 Sep 2022 07:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664204173; cv=none; d=google.com; s=arc-20160816; b=xNXtToo0eRzN9l3TJyjF8W/sVPfjXigRzCOlS6DZh7z1Q5y8YXe8MYvWUC29HDGAXZ bkkeCPkxt9AJeu340bTHsM4Xjvh6ejmP2V7A6Agqnm9po/1Vq+B3RKQL/DnEGF7mWmNn 4EjOkYLcrZDku8jh5dV0uOLR46xVwO38M4IVa9vm1SSYIATzFJsKDWxEyMKsKypWpxSZ grCpW2d2l69xPOzhoLCJgfzutFLLvF002KcMyGCt5OB8qjx8fjlS572aKNX+VpNts+Nc s0VBEjI0a4eurN3eW+InxKIBVkCG8uOYMn33gjGtzaJRIHjscotQY7mP1UefPAKa8cCk 9qcw== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FIHRxSY6V+zzl15F4vvObYqxHLfDtkzR9cwonipMTy4=; b=gd2+PquwM1o+thce3fiQHnUCqxNAOLwCiG96zlgyQfMaKUjw0dZz7l45Rwei3qeAKr +eWcSkB7qoFZLx6ut6Cdj+xEASTTZ96cPhrFbpOacBVdAHK+GPs0EYsaHpAs9g4x0XU/ CwHDecU4DazU+HDgpSVIDc1Dn4DspcbkJClBp63QLEmi1dTUqyBmQ8Vr6XwtK4TXNuEw gVFAfMwlk/ONnBzII0OfQzPVqUzNgCu8k/60s4Y74aCHEkIYNrEGb4xuC88AVUefurWu N/viZ2RjvomO+B+hAmchEsBNGR19Hheabu7pIDLRW9uPrBnNGqinthjcPsESK2jnKPmP ZNcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gvrdtGfY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x13-20020a170902ec8d00b001785b6840e5si13130303plg.245.2022.09.26.07.55.40; Mon, 26 Sep 2022 07:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gvrdtGfY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233752AbiIZO1k (ORCPT + 99 others); Mon, 26 Sep 2022 10:27:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234543AbiIZO1E (ORCPT ); Mon, 26 Sep 2022 10:27:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61EF714091; Mon, 26 Sep 2022 05:39:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=FIHRxSY6V+zzl15F4vvObYqxHLfDtkzR9cwonipMTy4=; b=gvrdtGfYanGL5Zv0aDMToZN85f +xqWVNEQnFt5COC6g8v2Vtsw900/hQjSCEAAArEl6LemRrxzyUmGTygvB3+ujY6oKmZ/odrLtahEP eaadMPRHDyYAxjCQTSbwEy9sx3Pc63jDaDiW7hyaauMFMqP2ESXJ/gIpdKDUgSqzsDhwAK4n2VayX Bv+UrTWjnmSk4cGEo8bv3xtK4yWhx2vqhtQkLAUV5ia8PlWKA90afqen7TRND7r436u/quR21gItg bN2orRDwoMTEjyFEI7brjAbFTHf5TalCLcTC1skSRts4y7bThtfeyIEGT2haZaPPAQbwxqk+IskVd UdQAQmRg==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ocnOQ-00ASmC-3H; Mon, 26 Sep 2022 12:39:26 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 81D9D3002F1; Mon, 26 Sep 2022 14:39:21 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 41A152B123E2B; Mon, 26 Sep 2022 14:39:21 +0200 (CEST) Date: Mon, 26 Sep 2022 14:39:21 +0200 From: Peter Zijlstra To: Sami Tolvanen Cc: linux-kernel@vger.kernel.org, Kees Cook , Josh Poimboeuf , x86@kernel.org, Catalin Marinas , Will Deacon , Mark Rutland , Nathan Chancellor , Nick Desaulniers , Joao Moreira , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-arm-kernel@lists.infradead.org, llvm@lists.linux.dev, hjl.tools@gmail.com Subject: Re: [PATCH v5 00/22] KCFI support Message-ID: References: <20220908215504.3686827-1-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220908215504.3686827-1-samitolvanen@google.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 08, 2022 at 02:54:42PM -0700, Sami Tolvanen wrote: > KCFI is a forward-edge control-flow integrity scheme in the upcoming > Clang 16 release, which is more suitable for kernel use than the > existing CFI scheme used by CONFIG_CFI_CLANG. KCFI doesn't require > LTO, doesn't alter function references to point to a jump table, and > won't break function address equality. > > This series replaces the current arm64 CFI implementation with KCFI > and adds support for x86_64. > > KCFI requires assembly functions that are indirectly called from C > code to be annotated with type identifiers. As type information is > only available in C, the compiler emits expected type identifiers > into the symbol table, so they can be referenced from assembly > without having to hardcode type hashes. Patch 6 adds helper macros > for annotating functions, and patches 9 and 20 add annotations. > > In case of a type mismatch, KCFI always traps. To support error > handling, the compiler generates a .kcfi_traps section for x86_64, > which contains the locations of each trap, and for arm64, encodes > the necessary register information to the ESR. Patches 10 and 22 add > arch-specific error handlers. > > To test this series, you'll need a ToT Clang toolchain. The series > is also available pn GitHub: > > https://github.com/samitolvanen/linux/commits/kcfi-v5 As mentioned at plumbers, my only concern is somewhat excessive use of CFI_CLANG as oposed to something more compiler neutral. But I suppose that's something we can cleanup/fix when GCC grows support for this. Acked-by: Peter Zijlstra (Intel) Tested-by: Peter Zijlstra (Intel) (as in I ran kCFI + call-depth-tracking + FineIBT on a bunch of hardware) HJL, can you look at adding kCFI support to GCC ?