Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp677901pxb; Fri, 16 Apr 2021 15:39:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyymagapkwfzS55F6LNzC7S2aHXEZ3E06GLIyh7Q9e+XSwQziTxOF7qJoGp65yt/gsQmd/r X-Received: by 2002:a17:90a:e507:: with SMTP id t7mr11889934pjy.14.1618612751815; Fri, 16 Apr 2021 15:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618612751; cv=none; d=google.com; s=arc-20160816; b=p+xZJYSec0aDqbdp3Bb7wmidT+6wh5z/8XysWgBZdLuEPPZe2F7rZlApaV7AYSSEqN 3edX6yByCZYDPBiGBgP+zD5RLpZ6cEI0BytKf9bDcU9taZDmOWsw9Ue0UoscHE8z6hKR Ai9mr57ZffDwMSaV+UpiUKzXXR2KWziLmAuSoXGjk6yoPqRRjQzY4VjQ1M2l/nsFO1HH XNKiLEdTuPFR6dOHrHv4Uabow5PFfKwXHgGZ6shBtOl+oBinGPnAFuLHO1vpCJIq9V9V HRDEzurhHbs3rsv9tZkIrtEpZ4pz7wtgzLS/mrs7XDutvhLtnNrKM3x3cXZlkVoVUtY6 6gow== 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=NDhS9ea/Ghy92VBWAgivjVBpdpN6nWgmnBRq9q7wlPI=; b=kXx2wobvkHAH5krshYLbiRkXSwqjVuTd8r8ptuv8dkZQJAL+A8da2g0CTE9mpVVcyJ F1PIcVxKgYKc+cclXB/njMpPb43JqiXQfA4/x4RaQKnb37ftgKLAtsUp2I6o/L340Yu3 C2V0vkI2ePe4oXyxR9k2v+Bgu2VWEZPUS454XW3ZW7ywW/PoXl0pk2oN34Yj8Ia3FDEx Yt1QoB0qK2YyPosG1RBXCg89c3hhWuUHFOfcLKGcQrzfGIHPnHp4EKDi5zQExyAQewvw zMxIFOtc/UBKmGKKnY1yNSTC0/8hhXDq9amUMbZfOqyEe4to31hb+QxV+rXXShzVwXGT jQ9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=D8UkrwRL; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id me5si7676996pjb.44.2021.04.16.15.38.59; Fri, 16 Apr 2021 15:39:11 -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=@chromium.org header.s=google header.b=D8UkrwRL; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231898AbhDPWiT (ORCPT + 99 others); Fri, 16 Apr 2021 18:38:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231296AbhDPWiQ (ORCPT ); Fri, 16 Apr 2021 18:38:16 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB5E5C061574 for ; Fri, 16 Apr 2021 15:37:49 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id h15so1577305pfv.2 for ; Fri, 16 Apr 2021 15:37:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=NDhS9ea/Ghy92VBWAgivjVBpdpN6nWgmnBRq9q7wlPI=; b=D8UkrwRL94aleXQSNpyGSiYhqv/HLOAHwV5Ki9OjU8tDlDV2mvmiEPsCX7g46fNsKP 13Cjxc9eXQo7iZcFwO+hiZCkUp7SvAnf2ZEP2ye+dUsmgDNFEpLdEgFk8QAwdhfbF9jB QzyvzX7nISRqZelsff9tB0CnX9wLJPmVHM7A4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=NDhS9ea/Ghy92VBWAgivjVBpdpN6nWgmnBRq9q7wlPI=; b=OFwhpxDbLimu6ScFC35qQoCKsv+KlT8Fwmy44DNf/15kWGgCTtp6j6UZkDzeNo4dtr OJZ00+HPqU76hm+Mrgh0swPSdNFs4Nu0ToRfsYKVC3YqoUPaYXpxl/tyuTOlrBkMiq3y I3SdGMNqCIOtiAYUrp7AI07bk9ekV4u5gt+4nChU3SaUA1A06qt0W37EwDyOEcpSOXYJ IW+gG0K5HSOxIF/CRP4NRXS2gvUP6sXo9pkyZFEirVw9A4fLHkGBd7+hgyDPIQhC21hT XoFI4BUlro7FFfv9HmatznAnPNBolK1Zuml10tZMIczVxbUdoR+QutNLu+z+YDKF7Fed taLA== X-Gm-Message-State: AOAM533AhbIrf2t3+gy+g2wOzoUKkI88zsoUIYYqsI8I9Zu+VEoaf98K f/fSPxPUboB7c+JoP3SqyoQ8Eg== X-Received: by 2002:aa7:8486:0:b029:250:f6fc:ae93 with SMTP id u6-20020aa784860000b0290250f6fcae93mr9648698pfn.39.1618612669362; Fri, 16 Apr 2021 15:37:49 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h21sm2461475pfh.130.2021.04.16.15.37.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Apr 2021 15:37:48 -0700 (PDT) Date: Fri, 16 Apr 2021 15:37:47 -0700 From: Kees Cook To: Andy Lutomirski Cc: Borislav Petkov , Sami Tolvanen , X86 ML , Josh Poimboeuf , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Sedat Dilek , linux-hardening@vger.kernel.org, LKML , clang-built-linux Subject: Re: [PATCH 05/15] x86: Implement function_nocfi Message-ID: <202104161529.D9F98DA994@keescook> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()). So, instead of a cast, a wrapper is used to bypass instrumentation in the very few cases its needed. (Note that such a wrapper is no-op without CFI enabled.) -- Kees Cook