Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp885055pxb; Wed, 27 Oct 2021 14:27:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz651D9Cs6Phae5YEAxDWblpm3HMF+722sF9f/4CUlFqYJVlLMfdcgPLRU619f5qXG8YZ3A X-Received: by 2002:a17:906:d7b6:: with SMTP id pk22mr107187ejb.172.1635369965906; Wed, 27 Oct 2021 14:26:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635369965; cv=none; d=google.com; s=arc-20160816; b=tFg2020ePne7cLZjdi1Iy7sWgAO6mod+urUk+p1Gh1e2rK+3z/df2TSjoWonuZZaxE tDY+w0IxyduIoIFQfntKDMHh9vAzyfk/FjA6+i0LOtvWA2kOR9/c2NdF41g0Kw8Jl348 jmKrti/5YvJLwEDs1zKBLOXV5Kc3/nxCvJ7IwjdDsbRcjHXnO4zruc3m2HpZL4DmIrJF F2vWAHO8ygvdNfyxMG+i0nQVq15g/HXmn6T/s32RR7q4klh5GL11acjnyq/NNqlMmW8H 9raH+XmVGN63Ea+HTmeGNiuRSNZ272Vev1xZY6s0TLdO0Jh+p+5HmA6De1NXJzbBGuCn peuw== 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=a/axwY8nWNaBxTRi53jpnhiV68UM1lNZPNWkLRff/vg=; b=TuE5YykRVMM5sYA+MLeV6Ja0696B01mZCC8Hkrmy7ElQkBRjxoBdWutgDAfvltekzh 0r/ETCC0HN4h/Ce/mXHebLLtW+rVh/ll9Js+wVU3iNTOd3qh+qVOQkeHulIBCLz/QQ+d GUBRcOpHparbNw3H5B91CHq1iLO8zxp7OBjWM0OKxEUla7gWrMY3MBziR6xRoCrqOGxf cFyxTFoxTwluswIsaOYaFNWy38kd/dsi8OuiYdAaloX2S51TO3YVipb8w6Zdt/duwRvo 3aUZMlR9ZAR98HnSazXa4xlNFppuO/4XMI2bsj3Oi3jjrL24hwqSs6Kg2okze782Ws5v 7Fhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ZOpO6pkA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id sd12si1593609ejc.164.2021.10.27.14.25.42; Wed, 27 Oct 2021 14:26:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b=ZOpO6pkA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242072AbhJ0NHn (ORCPT + 97 others); Wed, 27 Oct 2021 09:07:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233332AbhJ0NHm (ORCPT ); Wed, 27 Oct 2021 09:07:42 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 265D3C061570; Wed, 27 Oct 2021 06:05:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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=a/axwY8nWNaBxTRi53jpnhiV68UM1lNZPNWkLRff/vg=; b=ZOpO6pkAKFsKCg4vFi+HjuH2ZL gVBb+6WZ8VUdqvqZtfQmTW3eW4xezlhoBE4YmsqILQTFlXY59lGfu3RkfS7flbwzPT8IieTibBP8k pKjwuLEr8uKEzhP6D/EhfI+raVKdGX8juPVTAEhfIVYE5WpF3u5KESgkWHSp4Z+HGrpadKUXcfmWn RZ7pZuvLMwpx844cZ2CoSJiiftaoxRv9Px5jwSJE4NkrdhGqw6MI7K5MQi6p0mhJtIzZu0M7PqSBm 9JGTRzVfl0tNs+ClAeL4KVXcDfhHaCbvanj2r4JFYCf19KOIedsePqhAcvyuZg162EPyFQpc/S8AI OfQiWcnQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfibw-00CYaa-LV; Wed, 27 Oct 2021 13:04:56 +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 (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id B0AE83001BF; Wed, 27 Oct 2021 15:04:55 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 906B82C27DC2E; Wed, 27 Oct 2021 15:04:55 +0200 (CEST) Date: Wed, 27 Oct 2021 15:04:55 +0200 From: Peter Zijlstra To: Ard Biesheuvel Cc: Mark Rutland , Sami Tolvanen , X86 ML , Kees Cook , Josh Poimboeuf , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, Linux Kernel Mailing List , llvm@lists.linux.dev Subject: Re: [PATCH v5 00/15] x86: Add support for Clang CFI Message-ID: References: <20211013181658.1020262-1-samitolvanen@google.com> <20211026201622.GG174703@worktop.programming.kicks-ass.net> <20211027120515.GC54628@C02TD0UTHF1T.local> <20211027124852.GK174703@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211027124852.GK174703@worktop.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 27, 2021 at 02:48:52PM +0200, Peter Zijlstra wrote: > On Wed, Oct 27, 2021 at 02:22:27PM +0200, Ard Biesheuvel wrote: > > On Wed, 27 Oct 2021 at 14:05, Mark Rutland wrote: > > > > > Should not this jump-table thingy get converted to an actual function > > > > address somewhere around arch_static_call_transform() ? This also seems > > > > relevant for arm64 (which already has CLANG_CFI supported) given: > > > > > > > > https://lkml.kernel.org/r/20211025122102.46089-3-frederic@kernel.org > > > > > > Ugh, yeah, we'll need to do the function_nocfi() dance somewhere... > > > > > > > Sadly, that only works on symbol names, so we cannot use it to strip > > CFI-ness from void *func arguments passed into the static call API, > > unfortunately. > > Right, and while mostly static_call_update() is used, whcih is a macro > and could possibly be used to wrap this, we very much rely on > __static_call_update() also working without that wrapper and then we're > up a creek without no paddles. Specifically, we support code like: struct foo { void (*func1)(args1); void (*func2)(args2); } struct foo global_foo; ... DEFINE_STATIC_CALL_NULL(func1, *global_foo.func1); ... __init foo_init() { // whatever code that fills out foo static_call_update(func1, global_foo.func1); } ... hot_function() { ... static_cal(func1)(args1); ... } cold_function() { ... global_foo->func1(args1); ... } And there is no way I can see this working sanely with CFI as presented. Even though the above uses static_call_update(), we can't no longer use function_nocfi() on the @func argument, because it's not a symbol, it's already a function pointer. Nor can we fill global_foo.func1 with function_nocfi() because then cold_function() goes sideways.