Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7463229rwb; Tue, 15 Nov 2022 12:42:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf53/JrRtskl2Zo/rO57TS7bMHHc3fsIDcD16pdB48bLUc1A1S3RI7Lk6OvJuAz0S3ItFY8o X-Received: by 2002:a05:6402:1859:b0:468:51b0:295 with SMTP id v25-20020a056402185900b0046851b00295mr3090897edy.319.1668544937065; Tue, 15 Nov 2022 12:42:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668544937; cv=none; d=google.com; s=arc-20160816; b=Z02DusBcPqZd9i9cO0eCnKljYadyKbo1zgdrBt+2JPfgXdeymHmU9R6I7/qMP5KBpS Fz9cxHBKqGBuyvERiyKpOKRLWZjzQ+Ix3c2hiZ7P2JInX0/GyUf7+PJJ6mlFQGUsb6vg iSD+bfe6IDnSPLSTO0fDO0SV2Dx5IDpipJmkotQ5uV3T5LtsLOLa1XFWMvrcJ9HukMnh bflqBxJcYToZbOTkT++t7B9AwSQrbHBmZdGcUHfm1uNBqEIQu97tj7GmVNmIM5b07nZf thp8XlHmkqBktkQ1NqgJvxZfoTZ0yx8mChSRZq31xJSHUCqhUS4SCAwLlh2xWfJpVl+l /+WA== 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=QQkajeEpoN84cJxFGz64eHjqDfcA7nBybGgFO0D93eo=; b=R335bWDRgQf+u9Ti2zZNNDgyr8nAZLDqZkzKIYllc7fpTCOLJ2K425f0mS2LULQKJB teV4iFLRWz6eBAujMB9PBMO9aaSyeX7v+gPVZ5ghWJNzZ3h6j63LG7BRJGNJqzp3HBdA OdM3FTHimFCTPY8CG5DWKUWCT3JFK9gIDvSNy5oQwmvu8Yigf5ikNhwf6mF81Hz6IZsq 2EK0obwCLu9yNNm22SMfLr76YlCYmlK6eAiBapQt9JuGBG84bUwbG9LenCJqTziat30q fOCxx3gGenlQQUFdmIFTqK1/Hy4NFqX2/vtiAPkcQzTrIILhkqeroUSFZJUYOxDH92Lg Ps1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EytyFFGB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb34-20020a1709071ca200b007ae25728169si5862944ejc.800.2022.11.15.12.41.55; Tue, 15 Nov 2022 12:42:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=EytyFFGB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229642AbiKOTjA (ORCPT + 90 others); Tue, 15 Nov 2022 14:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230326AbiKOTiz (ORCPT ); Tue, 15 Nov 2022 14:38:55 -0500 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C8E4FD3E; Tue, 15 Nov 2022 11:38:54 -0800 (PST) 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=QQkajeEpoN84cJxFGz64eHjqDfcA7nBybGgFO0D93eo=; b=EytyFFGBO97UFkfGRJWHbOAzTY B5D16bY6oC9pjvUTguztKlVv7VolOys1CugodVjDbj6id1r4v9Ph9I9ICK1UXbKx/TYCjlqtWD78K bbL9certGUcllrnzt90Qe5wBuaNxqar0ZRxRGtQUz4u8rhr8NK8KkUCu9SauwlpzKD5iZZrWC3ADk qIEr5jToB2/IhLsw7fOuz4BxHpGeE4jV78P4NrC5kVg4b+JT0zSr7R66PxdXP2BVvI07Dvx59uLXD 1fcFLFjCmZvkhc7U7o/h/UpZ7pyiR58BwmX3T6aWwt1wFeqzSeLsATngHULAXetyjuODnIxTkH6/l 4QfxOGfw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1ov1lT-00GYBk-0h; Tue, 15 Nov 2022 19:38:35 +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 (4096 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 8978D3010ED; Tue, 15 Nov 2022 14:03:57 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 6980020162835; Tue, 15 Nov 2022 14:03:57 +0100 (CET) Date: Tue, 15 Nov 2022 14:03:57 +0100 From: Peter Zijlstra To: Rick Edgecombe Cc: x86@kernel.org, "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H . J . Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Randy Dunlap , "Ravi V . Shankar" , Weijiang Yang , "Kirill A . Shutemov" , John Allen , kcc@google.com, eranian@google.com, rppt@kernel.org, jamorris@linux.microsoft.com, dethoma@microsoft.com, akpm@linux-foundation.org, Mark Rutland , Will Deacon , broonie@kernel.org Subject: Re: [PATCH v3 24/37] x86: Introduce userspace API for CET enabling Message-ID: References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-25-rick.p.edgecombe@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 15, 2022 at 01:26:23PM +0100, Peter Zijlstra wrote: > On Fri, Nov 04, 2022 at 03:35:51PM -0700, Rick Edgecombe wrote: > > From: "Kirill A. Shutemov" > > > > Add three new arch_prctl() handles: > > > > - ARCH_CET_ENABLE/DISABLE enables or disables the specified > > feature. Returns 0 on success or an error. > > > > - ARCH_CET_LOCK prevents future disabling or enabling of the > > specified feature. Returns 0 on success or an error > > > > The features are handled per-thread and inherited over fork(2)/clone(2), > > but reset on exec(). > > > > This is preparation patch. It does not implement any features. > > Urgh... so much for sharing with other architectures I suppose :/ > > The ARM64 BTI thing is very similar to IBT (except I think their > approach to the legacy bitmap is much saner). > > Given that IBT isn't supported and needs the whole legacy bitmap mess, > do we really want to call this CET ? Why not just make a Shadow Stack > API and tackle IBT independently. On that; ARM64 exposes PROT_BTI (to be used by mprotect()) and have an ELF_ARM64_BTI note for the loader to bootstrap things. We could co-opt that same interface and instead of flipping actual PTE bits, have this thing manage the legacy bitmap -- basically have the legacy bitmap function as an external PTE bit array (in inverse). Basically, have every page mapped PROT_EXEC set the bit in the legacy bitmap while every page mapped PROT_EXEC|PROT_BTI will have the legacy bitmap bit to 0. And as long as there is a single 0 in the bitmap, the feature is enabled. (obviously we can delay allocating the bitmap until the first PROT_EXEC mapping that lacks PROT_BTI)