Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp536566rwb; Tue, 27 Sep 2022 00:37:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5PpjVdByDfffjCD0yHWs2IqUlmd2g1He9DsbMyQGbKAnQuVUXBAbzShji8kK7yJf2vPyHS X-Received: by 2002:a17:907:948e:b0:783:91cf:c35a with SMTP id dm14-20020a170907948e00b0078391cfc35amr7315830ejc.366.1664264279165; Tue, 27 Sep 2022 00:37:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664264279; cv=none; d=google.com; s=arc-20160816; b=P7qJluGAbaaHG2kkjkyuh//OZPfCWmekJ5zF8aacFT3741Vsa18FA8mFpSPkjFiPWa Rxvb8GIw/fOq6MHRftQ/mwlVaoL4nU2XzNqG87+3Eq73GIWc7wU4vd1hvajcv/Kpiu9v HSJoMd0jiYP71uQtZBB2trphpRsQ9rLzE9Toe/OZ8H0Gd+j1YxH8dEbLV9kZVIuzLK2z FdC28PiSasrHh8oE6xJQKfojh0ef1mj64qVUuXsBtNff5aUG/MhoHzSN/r9E6VDi033p +CUmda/w0GKXMmfh9mBghU2KUiX6WNtW3EoiR+Ooa8vZ8b66nOldm+iqKC7MC5CRxsHV DKlw== 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=tls49PLjZOzAeRxCnxqtOV072QtfY6ihsqweRWOv07c=; b=iGesYfV4ocqNamJCRI/gsOJUEPGXkdp9gJ/ZJU7gYX7Q7q1taiHPwvBdnNOC79axsY q783W4iA8Zte5AqwV5a2ZEvCZYbYgjZaPEcSgg4fKWP56EY7Cqq+YhYpnFf3QOK2I2R/ nrt/gMkZgQF0WEE0DRJV1g/gEEnS31cG3WOqEXzfzm9xqlu2mOinYs6c0TZrUVu9oeYG 8YM2dGzUjvP1ooYRATuhbCVCVUi60qnsY1rlGMCkDZlPC9rR58/QFNVbNnI0iB0m+PKs oBvmwTZ58SS0llIdlW6NROTzKlMU2Ga3hM0ARwj+0L6IF+naeqF+yyDB0040QS+VR6pL a5cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=bJWcivEs; 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 bh9-20020a170906a0c900b00781ea213f99si461199ejb.173.2022.09.27.00.37.33; Tue, 27 Sep 2022 00:37:59 -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=bJWcivEs; 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 S229512AbiI0HaO (ORCPT + 99 others); Tue, 27 Sep 2022 03:30:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbiI0HaN (ORCPT ); Tue, 27 Sep 2022 03:30:13 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 776DD20BEC; Tue, 27 Sep 2022 00:30:07 -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=tls49PLjZOzAeRxCnxqtOV072QtfY6ihsqweRWOv07c=; b=bJWcivEsmM2FcxwzWZpWJxbPSh 8f/Vx3JR1uW7SRoOH1n+ALAE7l/EAofilHwoZUZkVO9rVAHbrRXEic7AmZaaub+Qxth90vNV2XkOs EOrIS4oTZt2XIEqhE0YHAWB0XYYm6YYulqSY6q18Lglwkm6d3UP8Kx64koPk/md3ZzGG5YvP3OM12 hmfuylbAjgYQQGnHucDxXAGc04Yaxg8XPEHw28DE1s0n6f1UhGzwkuxWSVzr7dBujRBNt/vqhU2Cu SmbPFQdQIs8nuZ1TFxNtHVKa6aPX01t4Z31J+KgoB/4KoiiJWcqkbWCf0ioHcMd9WUZ45P4JohRTl 7mLiCVOw==; 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 1od52L-00BEXq-Bw; Tue, 27 Sep 2022 07:29:49 +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) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 96ABF3001D6; Tue, 27 Sep 2022 09:29:44 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5ACE22022F86A; Tue, 27 Sep 2022 09:29:44 +0200 (CEST) Date: Tue, 27 Sep 2022 09:29:44 +0200 From: Peter Zijlstra To: "H.J. Lu" Cc: Sami Tolvanen , 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 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: 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 Mon, Sep 26, 2022 at 01:16:04PM -0700, H.J. Lu wrote: > On Mon, Sep 26, 2022 at 5:39 AM Peter Zijlstra wrote: > > > > 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 ? > > Adding -fsanitize=kcfi to GCC is a big effort. Please open a > GCC bug: > > https://gcc.gnu.org/bugzilla/enter_bug.cgi?product=gcc Here goes: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107048