Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2595990pxb; Mon, 19 Apr 2021 09:11:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzt7fYhprH1uxXvcOt0N4isRMvpQG4sEJj32CpIJ/G/1j0mLAxcouctLR6JQP7MNg8WCqbl X-Received: by 2002:aa7:cc98:: with SMTP id p24mr26526555edt.187.1618848689101; Mon, 19 Apr 2021 09:11:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618848689; cv=none; d=google.com; s=arc-20160816; b=vv3g/M2NfZB9t4KaOqONPyTyXHuZ509ksA/P+jMJrkMqJwPPG2rCCjRA1yVvf9e98S 6TCWw/jUI2maEUqpfcHqfy1PRX+zuybdeRZHUis5l+0qyUbYA1VhP2AMOtGWQATPDIy0 UeuSb5e7CZego4jwy+Q+5Grw1WAGYAyC5/bzjeiHSLZCTUl6gSGNMWu4h7Z3bmszRdc9 IMD5xV+7Syn7BBqExlXXXMYPnfcDttCUQL9jo1dIeksGPAwM7HmxpefYivy42OVvFe8o 3Z81/q4iUBRlkjdrHztg0c1g74ZPEtlyJf6izyPcfqC51hRKR434nmIiuMs/cHKb28i6 4ZVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=36vwzvQKHGNtNCW2ZUnMCMtobdyASLNJa9tZKeMvkEQ=; b=dcenVOCnUQTvtS3Sx6JG/yTKu3dzpw/IChD3SgiKYysHjqvWIGRBQxGr0g55sM2X7T f+oE31138HBxUYo4rZ3vHuRstffmtnBqnWHIH5x/wQt+HIVjsLuV3DW2RS9pzSOtr7rf S0KjbCuJk6wHzjD91KJoix3Eg1spUx45R8il0AyD+qy5bTcN8DKPCpepNrvTbXeqQSlg OyIlpLaiLLkQ/9CpStfuaS1QsxV0CzOcHYvz77HfgzlhblR4xQSol/X0dA1WTxZ7tluU qlP5h6+bLeghMZbX84LWBjhliNWCgFtq4ragppCg9ccubNOldnCsxJallmlunqbsfWIl znSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=czTjya+U; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ep14si11604118ejc.71.2021.04.19.09.11.06; Mon, 19 Apr 2021 09:11:29 -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=@google.com header.s=20161025 header.b=czTjya+U; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230213AbhDSPOa (ORCPT + 99 others); Mon, 19 Apr 2021 11:14:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232911AbhDSPOa (ORCPT ); Mon, 19 Apr 2021 11:14:30 -0400 Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BA0BC06174A for ; Mon, 19 Apr 2021 08:13:59 -0700 (PDT) Received: by mail-yb1-xb34.google.com with SMTP id i4so1595921ybe.2 for ; Mon, 19 Apr 2021 08:13:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=36vwzvQKHGNtNCW2ZUnMCMtobdyASLNJa9tZKeMvkEQ=; b=czTjya+URdUiMwXGnHagZwTFuPInlRrTc3wRPHOQw5l93EMk3BWr3PTm6Qb2J+tiMc 58cs6nPNphdDoVxv+Hkgbr21HhD3zEoZa4Xl7Mhd53JshzbevB0YxVeFFpSZHZ2mi7zO lER3lLDVLxfBRy9Ee0nGVzowhPXLnhRjRTKtZVjLCniQ5G80oGGtpVbVcp0LE1AVb/gN N3c1ewRFeTJh8qI3+8pGgAWjJQfQmh9X7HYlXYfvJ39RjjJrMXwtE0ljmLA5SkctCOfr M92Uh3HtEOaywf5vNGwsfIVeVmJQmTDYbKXPDnUaRwhMwUmMhby9KM4eFfaxLGcRowpL uFvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=36vwzvQKHGNtNCW2ZUnMCMtobdyASLNJa9tZKeMvkEQ=; b=OHBQmHcZqJSteiHyiSUnhOWGR3o762Fnwop+q3f5KarmJMPUbo9l+KR1NlGotNVqKg lOZ+qVpeL0mtMR2k5LZTM3iRc7Lpktwc6k/rICjLpTHZm9FPnn4v4GZ4DC07EMLEzYwa RKENlCH8EaV3Y9nL3aO7EBc2oryYVTA7ynqfzRHC+aLShMiKSgoHlz7GS7E9b85mj1Wt d0o3C5JOZv4cDNomweEMnyTBI89f7acb/Be8epJxTgQf25AWSC1QSAVkNfhGS0zrnZUc uh7JObUFmKPQ90HdRI9vX1gVDL+YQa4UG40ClnQXGyJVr1rp/uCHA7p/ESMJ0TEDcwF8 Xv0w== X-Gm-Message-State: AOAM5315oZ1zwRxx4b9fVW+WUmbPn3Hwy8YyQ5LwG/9KpKUW/6zetY8+ ot0XDpNfGjzMhfIF8G9AIRq5YJRmvj6FlX+lATe01Q== X-Received: by 2002:a5b:48c:: with SMTP id n12mr18798826ybp.273.1618845238403; Mon, 19 Apr 2021 08:13:58 -0700 (PDT) MIME-Version: 1.0 References: <20210416203844.3803177-1-samitolvanen@google.com> <20210416203844.3803177-6-samitolvanen@google.com> <20210416211855.GD22348@zn.tnic> <20210416220251.GE22348@zn.tnic> <20210416221414.GF22348@zn.tnic> <202104161529.D9F98DA994@keescook> <87fszpu92e.ffs@nanos.tec.linutronix.de> <875z0ltdv8.ffs@nanos.tec.linutronix.de> In-Reply-To: <875z0ltdv8.ffs@nanos.tec.linutronix.de> From: Sami Tolvanen Date: Mon, 19 Apr 2021 08:13:47 -0700 Message-ID: Subject: Re: [PATCH 05/15] x86: Implement function_nocfi To: Thomas Gleixner Cc: Kees Cook , Andy Lutomirski , Borislav Petkov , X86 ML , Josh Poimboeuf , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , linux-hardening@vger.kernel.org, LKML , clang-built-linux Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 17, 2021 at 3:16 AM Thomas Gleixner wrote: > > On Sat, Apr 17 2021 at 01:02, Thomas Gleixner wrote: > > On Fri, Apr 16 2021 at 15:37, Kees Cook wrote: > > > >> On Fri, Apr 16, 2021 at 03:20:17PM -0700, Andy Lutomirski wrote: > >>> But obviously there is code that needs real function pointers. How > >>> about making this a first-class feature, or at least hacking around it > >>> more cleanly. For example, what does this do: > >>> > >>> char entry_whatever[]; > >>> wrmsrl(..., (unsigned long)entry_whatever); > >> > >> This is just casting. It'll still resolve to the jump table entry. > >> > >>> or, alternatively, > >>> > >>> extern void func() __attribute__((nocfi)); > >> > >> __nocfi says func() should not perform checking of correct jump table > >> membership for indirect calls. > >> > >> But we don't want a global marking for a function to be ignored by CFI; > >> we don't want functions to escape CFI -- we want specific _users_ to > >> either not check CFI for indirect calls (__nocfi) or we want specific > >> passed addresses to avoid going through the jump table > >> (function_nocfi()). > > > > And that's why you mark entire files to be exempt without any rationale > > why it makes sense. > > The reason why you have to do that is because function_nocfi() is not > provided by the compiler. > > So you need to hack around that with that macro which fails to work > e.g. for the idt data arrays. > > Is there any fundamental reason why the compiler does not provide that > in a form which allows to use it everywhere? I'm not aware of a fundamental reason why the compiler couldn't provide a built-in here. This series attempts to work with what's available at the moment, and admittedly that's not quite ideal on x86. > It's not too much asked from a tool which provides new functionality to > provide it in a way which is usable. Sure, that's reasonable. I'll talk to our compiler folks and see how we can proceed here. Sami