Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp294008pxb; Wed, 27 Oct 2021 03:15:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzR7y5SEfV6pOQWKCiF3ZgRJhtWyLFPzSMEggunybiX5BUxS0I/F+64B1pWmxSyXTN2D3bz X-Received: by 2002:a17:90a:be17:: with SMTP id a23mr4963912pjs.82.1635329736869; Wed, 27 Oct 2021 03:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635329736; cv=none; d=google.com; s=arc-20160816; b=gVmgy8wCxKWuOmoZdDm/mX21LF+PHclxFDf2a/WmTqwDwoy2LN4L7FZjAVI5Jy5H0c DPsVrTVw4YVIcOleAAx3p7h4e7vMLRVSnRaS9mM62x2O2T46IbaoCXWLL02vQfjPnIs0 u0BMZmVxzjcwha7g7rFqBZIsyBaIIXaTaUvy+TM2Jt7FM3zxmiuN3MzskKQS10cm0pa8 iZ390u+6KY3bI4D9lk4QCxD4ikcaz/igRq/9+0LaUilb5LYu30MmsYLDHBrnc2MrskeU DkrHVPFdRacnw/bPD+/Ou4YCQtuhjXE1oyM3bLLv3Lbh/muCG66PPo9k3JXrIek+cWuM o6bQ== 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=xU4JYW+SGd/Y95RQ0MeB5uV9SkZbr+ZK8+zY2SI0BPI=; b=mshYJRpZ10AOj3tMtJ4wol1vd1UeXxPldsCqhty0qS/xWRYZWrKPTIEtFNPHITbI3Y PfCHixqcayVNWmbkaYIKZLG9bCs22uXz0jADZgIn/T5cmuxIA6vlLDt1Qw5i1oOrym7I oSxqeyOAcQ8E/crxLlr4lgPJP4shtWXor/vtXgAf8kZEH7eYWVV/tSEuJyo3KoVzTkkX hv37n0F4Z8d+jIurdr+AfB+QpGuURQR+iAugSCZO6eUfEpFnxQbvljR5wFpGQ5Fw02QT nYJqW7a3bIR7GQSq7YUHpTTwob1NPj1q/wfNX0g3vMzpl3kaaZWsaunoDR39JuJZ3LV1 AiMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=gXHGEsyb; 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 f16si35057074pfv.82.2021.10.27.03.15.23; Wed, 27 Oct 2021 03:15:36 -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=casper.20170209 header.b=gXHGEsyb; 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 S236972AbhJZUWF (ORCPT + 99 others); Tue, 26 Oct 2021 16:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52194 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231211AbhJZUWE (ORCPT ); Tue, 26 Oct 2021 16:22:04 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C42C4C061570; Tue, 26 Oct 2021 13:19:40 -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=xU4JYW+SGd/Y95RQ0MeB5uV9SkZbr+ZK8+zY2SI0BPI=; b=gXHGEsybTuDuZ4f5Zi9d+7JLfV iks1F4dTG0BdQG4mJ3OhfCcHhf1H8wtTmpoV4FUjTUGjEKSlG06Yg1atCfre5w2lP3qWsHYvgph9G gdjDa4RhbPmPiNjYAng3fEyuA+UL2fxKHjSjho+C4PA7NvFY+UK+vz9l1D8Z0POLeKfHGGlC32ZX2 aNXTY8qSlMfMr2bP6xL7rbT5yun+AsNKxGwyPEd6u8Bcd5k8SJRf7ZV1GroH5X85rW69fY2GnuQrf SgIB9tFhfeHsW2WVE6ptEjR6HhmwxbFRj2+QewRzyTtdMRnXbJ8IxK+YSGjobZqRN+pwwC1ZnsvJf NWGXANeg==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfSrt-00H8Ph-QF; Tue, 26 Oct 2021 20:16:52 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id 48E92981FD5; Tue, 26 Oct 2021 22:16:22 +0200 (CEST) Date: Tue, 26 Oct 2021 22:16:22 +0200 From: Peter Zijlstra To: Sami Tolvanen Cc: x86@kernel.org, Kees Cook , Josh Poimboeuf , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , Steven Rostedt , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, ardb@kernel.org, mark.rutland@arm.com Subject: Re: [PATCH v5 00/15] x86: Add support for Clang CFI Message-ID: <20211026201622.GG174703@worktop.programming.kicks-ass.net> References: <20211013181658.1020262-1-samitolvanen@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211013181658.1020262-1-samitolvanen@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 13, 2021 at 11:16:43AM -0700, Sami Tolvanen wrote: > This series adds support for Clang's Control-Flow Integrity (CFI) > checking to x86_64. With CFI, the compiler injects a runtime > check before each indirect function call to ensure the target is > a valid function with the correct static type. This restricts > possible call targets and makes it more difficult for an attacker > to exploit bugs that allow the modification of stored function > pointers. For more details, see: > > https://clang.llvm.org/docs/ControlFlowIntegrity.html So, if I understand this right, the compiler emits, for every function two things: 1) the actual funcion and 2) a jump-table entry. Then, every time the address of a function is taken, 2) is given instead of the expected 1), right? But how does this work with things like static_call(), which we give a function address (now a jump-table entry) and use that to write direct call instructions? 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 Or am I still not understanding this CFI thing?