Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4486812pxb; Tue, 2 Nov 2021 10:29:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzeHj3yWJUL9HAvSafcWNYQpFhnyzbBFb1o5ZNnmHkcryA37GEV/IDQfnPSgB/IyhFJdUaW X-Received: by 2002:a17:906:6087:: with SMTP id t7mr46456418ejj.206.1635874144827; Tue, 02 Nov 2021 10:29:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635874144; cv=none; d=google.com; s=arc-20160816; b=Tu+gKRr+9Mp22Tet2sapIejc3QEU1K5vMbmkgFZsI77d00nXDb43puqzJTVTnpGx34 d3r1Zo5+iRVD8lzpQ2CANRenRQ64bstu4rdaNdtfK+7tyM9svRod9rG548IOMqlD92io su7eEAZMdVhpfMgpxJR383b8HLt9oD9LlMIj9cObwWZdI6XbkekJJupM65STr2utIZ0E Ef4rIQKwJvBPt8+QngITirEzuIYGpfC1Tcu5SNOfeSFdQyKjVepO7GmjMZQwxvCF4ADI ake5N5s5l1ufT93N5VwpJQgoLml36h+zvjJrGnNtDA9p1oIKGGhJealxS441WwlYOoK6 9Yig== 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=myOqWBgPG0dYfqkI8IYrHgAqLHnpCmExkocszUv5gww=; b=gTIeMTmWENanFDHa2Ektp6Dsp7hHBMqsDQG1Wli7WvQmxZDmFHXPxp8wzV2SuxAMgZ r9iuTOr+YvxeKWc9t50ZExG6jnh8DCFZw+gAtUAoIZqtWB2ayE5Ez4JUYcTr4Euy8QTV ccy+ZZEVbWzOuU6tU/uNsX8KrbEeXeoPOW2LPWhPTbgHioNd4FqJeKR+ekMYJUChFTJ0 VcMWAFDKMosOc+v/gDMjxrb8H7Dzj761PUOfhpiMprGQeG80Yjt+r3vnlApi1cl7N33c rAiaFwTOMQBMbBrnesmbVn/g3mhFAIBny9QIVmG3Hh8xDGV68XJ+9gThxp53iRdC/kcI /bHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TKwPsswm; 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 b8si33539243edz.555.2021.11.02.10.28.39; Tue, 02 Nov 2021 10:29:04 -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=TKwPsswm; 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 S229684AbhKBR3H (ORCPT + 99 others); Tue, 2 Nov 2021 13:29:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230457AbhKBR3G (ORCPT ); Tue, 2 Nov 2021 13:29:06 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1E9DC061203 for ; Tue, 2 Nov 2021 10:26:31 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id s136so56444pgs.4 for ; Tue, 02 Nov 2021 10:26:31 -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=myOqWBgPG0dYfqkI8IYrHgAqLHnpCmExkocszUv5gww=; b=TKwPsswmiw8iIlN1erYAlJRZrSd5BMqlzwhXBspryv7/sxW7ziYzUFwoZX6v4eQ/Fd PdZbQv7+JzzhecFEW5a2g9Evt9CAEYO++aysSRwuoeHh/z03VJxQzNSwYEbWAlMuPj+h HRvYBwb9ss0Z7OgrkxA2LuKPm+MCxDPu7MB1I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=myOqWBgPG0dYfqkI8IYrHgAqLHnpCmExkocszUv5gww=; b=j5Q0StESknw45Ig2piXiOJu9PvVKQO67JsyuIAL+6PT3bm8vMx6T8FfO/5VN2E5GNO Lbs7P7CihpefoosIHUwUwVtzN/UpDaPLqrv5577jZEZAbSQr7BrXoAWI8zS8KBZfA2QD 5tgMk7atqCI5abQYzuvF8q4uW8mm9mYyxN1D8ro0ksHcIzuRYpJP2rXk8Pe/fi1wAJ0m Ag4c87ylIBazPyEvNNv+MuZ7FgQD2cuJO7KGol3vmpgmsdrBv4ZChQ4GAtGXe+KbGfGm 9M+uMddHU5R5u9udRcVG+TpFmI4L/R8yGTuocYEx5XFwfok0ohOOeXPIR2L7UWlK/MkQ nz1Q== X-Gm-Message-State: AOAM533iPe9zq3BNub9W+aZDaYYpyJxQLL+ODUUVxV1ueg8BkvBh0kBA ssoAjY0FWZNJYFTgbSzC2vrteA== X-Received: by 2002:a63:4b58:: with SMTP id k24mr21454195pgl.326.1635873991315; Tue, 02 Nov 2021 10:26:31 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c8sm3078586pjr.38.2021.11.02.10.26.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 10:26:30 -0700 (PDT) Date: Tue, 2 Nov 2021 10:26:29 -0700 From: Kees Cook To: Peter Zijlstra Cc: Ard Biesheuvel , Mark Rutland , Sami Tolvanen , X86 ML , 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: <202111021023.0E5188EC60@keescook> References: <20211027120515.GC54628@C02TD0UTHF1T.local> <20211027124852.GK174703@worktop.programming.kicks-ass.net> <202110270939.F5C79CC@keescook> <202110271430.2A3980217@keescook> <202110280958.22E5F74@keescook> <20211028202905.GO174703@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211028202905.GO174703@worktop.programming.kicks-ass.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 28, 2021 at 10:29:05PM +0200, Peter Zijlstra wrote: > Now, since code (on x86) is variable length, there are no spare bits in > the code address, but since static_call_key is aligned, we have spare > bits. It is those bits we use to encode TAIL (Bit0) and INIT (Bit1). > > If INIT, the address points to an __init section and we shouldn't try > and touch if after those have been freed or bad stuff happens. > > If TAIL, it's a tail-call and we get to write a jump instruction instead > of a call instruction. I think this is the part that I was missing: the information is about the _address_, but it's stored in the _key_'s low bits (regardless of the key's actual/masked key pointer). > [...] > Hope that clarifies things, instead of making it worse :-) It does help, yes, thanks! I will need to read it again and go follow along in the code, but yes, that helps explain it. -- Kees Cook