Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5601030rwb; Tue, 22 Nov 2022 02:13:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf5PRDMeI2fT1YBNoXXiCAGe4u1HkUmz3AyCFmJloDZQWiqix8f1IVZJBPjPpin/EApla+KX X-Received: by 2002:a17:906:c1d0:b0:7b4:64d3:e6f4 with SMTP id bw16-20020a170906c1d000b007b464d3e6f4mr4683787ejb.594.1669112011761; Tue, 22 Nov 2022 02:13:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669112011; cv=none; d=google.com; s=arc-20160816; b=CsogwA6fsrXRofr+dMSvj8PXdQmUuFKfkfu/ZKVSaPSr7Adk0uxIEIDoam7m0w8Tid dgxtCMmw03ZTHpBUuQALZYjq5ZQO/zH71qTYACcr8SwK0tqjipvFpNflpTN/6+ko5oku rP4MseIXLIbVjUvGZw/JODmH2oGglri5bmwyzVUCNzL7E3sA4U6NYMv7cX9jDf7b4P6b 4CYd5WRApbbATqrS3Mfz8vNXME/xnGMPGfBwbT62pEs2iKhq02YUmGIWzY6sKVs7gN9p lvzPQhNScwr0AGsl9ASorhrayXD+FXya0wbI8tpeIMqhe0nLuLUNtVznlfRkKNkd1Ch/ 3m4g== 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=wVQCmC03AiQ7yqrYlGrpmYY+51HvBpuM9bnXIvnHrcE=; b=RVMRmregLbcRSn7rjLZ6O7CXLHvtlzEgjYro/3ZTrSGn/x36s6vff7VaxRdjbPk+6B k558OEeybStj47P04PPxMfQkMOviVAxfp0d0fnoxGGZ7h4/3v5spHC1gRZxY5qgPfhTu DShJZGvGLXjiM+1ym6S18v2P2uDTRw1hnvO/R5uTNR/pooxMFXB0T13vwynyOxu2YcCQ XgCj8WwkUM1h/TCCEOP0zErlR4jlgMkZuozEeg+mUarTd20bNiKKXj/N2Lmgq+bEXROX OlOEzLtKpjjb90QBqxA6cOUEceyHu12ewGYzcw/Uja4A6ZT8ylQEvDKFQcIfE3CETFH5 ZylQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tBY2vKik; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020a05640227d000b0045a16f47a9fsi12327874ede.624.2022.11.22.02.13.09; Tue, 22 Nov 2022 02:13:31 -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=@kernel.org header.s=k20201202 header.b=tBY2vKik; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232382AbiKVJhF (ORCPT + 91 others); Tue, 22 Nov 2022 04:37:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232156AbiKVJhD (ORCPT ); Tue, 22 Nov 2022 04:37:03 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F05A4A055; Tue, 22 Nov 2022 01:37:02 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DDAD3615D7; Tue, 22 Nov 2022 09:37:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68428C433D6; Tue, 22 Nov 2022 09:36:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669109821; bh=7wpu88Q6B2Kkm7KKjQcA0/8wvOjYoaetfEppOc8/LrQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tBY2vKikg0x96nQXt+AZQCh4q2OfzV+uadi3H6VV6L3w+cJ59JhcNem7fCPrHkIcN E8JP1Y58itlhsaVm+Kq/CKnkSXLu263e4xIoFUlMaqKQh1/QO8RcbsGYjdjdtCwh0R 5OFrI5sKkBOQlC3X9n+nBLpT9LNQyG71hf9Bp1/BmPP3k3BPyslhYlTvmeaqUQE5AN vG2RXMynurkwvAYVPn4hJwUPjELYfPXpxRSd14Ft6URqjU3hd+EN47CIIb5eWReXQk 0oa2UIVkMOcTUKDXxQMCQstO/5rMhb28sqTUy6o643p6EdsyPkLGx+LDBMTuYjVlzo 1vcd54Ioazxwg== Date: Tue, 22 Nov 2022 11:36:39 +0200 From: Mike Rapoport To: "Edgecombe, Rick P" Cc: "bsingharora@gmail.com" , "hpa@zytor.com" , "Syromiatnikov, Eugene" , "peterz@infradead.org" , "rdunlap@infradead.org" , "keescook@chromium.org" , "Yu, Yu-cheng" , "Eranian, Stephane" , "kirill.shutemov@linux.intel.com" , "dave.hansen@linux.intel.com" , "linux-mm@kvack.org" , "fweimer@redhat.com" , "nadav.amit@gmail.com" , "jannh@google.com" , "dethoma@microsoft.com" , "kcc@google.com" , "linux-arch@vger.kernel.org" , "bp@alien8.de" , "oleg@redhat.com" , "hjl.tools@gmail.com" , "Yang, Weijiang" , "Lutomirski, Andy" , "jamorris@linux.microsoft.com" , "arnd@arndb.de" , "tglx@linutronix.de" , "Schimpe, Christina" , "mike.kravetz@oracle.com" , "x86@kernel.org" , "linux-doc@vger.kernel.org" , "pavel@ucw.cz" , "john.allen@amd.com" , "akpm@linux-foundation.org" , "mingo@redhat.com" , "Shankar, Ravi V" , "corbet@lwn.net" , "linux-kernel@vger.kernel.org" , "linux-api@vger.kernel.org" , "gorcunov@gmail.com" Subject: Re: [PATCH v3 35/37] x86/cet: Add PTRACE interface for CET Message-ID: References: <20221104223604.29615-1-rick.p.edgecombe@intel.com> <20221104223604.29615-36-rick.p.edgecombe@intel.com> <223bf306716f5eb68e4f9fd660414c84cddd9886.camel@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Mon, Nov 21, 2022 at 03:52:57PM +0000, Edgecombe, Rick P wrote: > On Mon, 2022-11-21 at 09:40 +0200, Mike Rapoport wrote: > > On Thu, Nov 17, 2022 at 07:57:59PM +0000, Edgecombe, Rick P wrote: > > > On Thu, 2022-11-17 at 12:25 +0000, Schimpe, Christina wrote: > > > > > Hmm, we definitely need to be able to set the SSP. Christina, > > > > > does > > > > > GDB need > > > > > anything else? I thought maybe toggling SHSTK_EN? > > > > > > > > In addition to the SSP, we want to write the CET state. For > > > > instance > > > > for inferior calls, > > > > we want to reset the IBT bits. > > > > However, we won't write states that are disallowed by HW. > > > > > > Sorry, I should have given more background. Peter is saying we > > > should > > > split the ptrace interface so that shadow stack and IBT are > > > separate. > > > They would also no longer necessarily mirror the CET_U MSR format. > > > Instead the kernel would expose a kernel specific format that has > > > the > > > needed bits of shadow stack support. And a separate one later for > > > IBT. > > > > > > So the question is what does shadow stack need to support for > > > ptrace > > > besides SSP? Is it only SSP? The other features are SHSTK_EN and > > > WRSS_EN. It might actually be nice to keep how these bits get > > > flipped > > > more controlled (remove them from ptrace). It looks like CRIU > > > didn't > > > need them. > > > > > > CRIU reads CET_U with ptrace(PTRACE_GETREGSET, NT_X86_CET). It's done > > before the injection of the parasite. The value of SHSTK_EN is used > > then to > > detect if shadow stack is enabled and to setup victim's shadow stack > > for > > sigreturn. > > Hmm, can it read /proc/pid/status? It has some lines like this: > x86_Thread_features: shstk wrss > x86_Thread_features_locked: shstk wrss It could, but that would be much more intrusive than GETREGSET because currently /proc parsing and parasite injection don't really interact. If anything, arch_prctl(ARCH_CET_GET) via ptrace would be much nicer than /proc. -- Sincerely yours, Mike.