From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9C32C4332F for ; Tue, 22 Nov 2022 09:37:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2983F6B0071; Tue, 22 Nov 2022 04:37:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 248A16B0073; Tue, 22 Nov 2022 04:37:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 110B98E0001; Tue, 22 Nov 2022 04:37:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 027726B0071 for ; Tue, 22 Nov 2022 04:37:04 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id D0503120FBF for ; Tue, 22 Nov 2022 09:37:04 +0000 (UTC) X-FDA: 80160574368.06.9330820 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf22.hostedemail.com (Postfix) with ESMTP id 2B693C0008 for ; Tue, 22 Nov 2022 09:37:03 +0000 (UTC) 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 ams.source.kernel.org (Postfix) with ESMTPS id 85EF3B81604; Tue, 22 Nov 2022 09:37:02 +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: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669109824; a=rsa-sha256; cv=none; b=5THwkKclUNmSX9Cub058kOkcBZK69HYo+0Pb0Kr9pYEE3qjhhRqqOI/wbBaBPPyIJrDSTt wt7jZuTAS/Tgvqngu7sX0UHyA9w7wjt6s66M7NmWfrr9ygqri5DsjVJM9LPl8Jk7eK8k1V 3MLdGv/pOk4OfBmnM/MImq/26A8IyXY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tBY2vKik; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669109824; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wVQCmC03AiQ7yqrYlGrpmYY+51HvBpuM9bnXIvnHrcE=; b=ErH+EwwUg9haQHpz6lTuSe+2lqAzA4dK+ioggfwfLlIfxPN8m1RIPiTmkfx7eRrPBgtqva KjKWBnDDKeDIYIx4ZtrwAgYt8XScLUnguqD8kPU/tg8At4Y8TpcfE3HIzAaT3Xww/dn9pM kTwp7T8Ukt0lzmqzotJ+NiAvCKX8Bnw= X-Stat-Signature: rsc9hkpesjf4h7ikxyjgbajuytyf85w6 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 2B693C0008 Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tBY2vKik; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf22.hostedemail.com: domain of rppt@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=rppt@kernel.org X-Rspam-User: X-HE-Tag: 1669109823-59061 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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.