Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3123879pxm; Mon, 28 Feb 2022 12:32:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxelcHc9JGMgthfoKjMXQF2lU7ZGawadNuI61Jww5MVxXTEu22mNcfTNrUWYqlLaG6SGGmy X-Received: by 2002:a17:90a:4590:b0:1bc:4afa:1778 with SMTP id v16-20020a17090a459000b001bc4afa1778mr18532826pjg.14.1646080332978; Mon, 28 Feb 2022 12:32:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646080332; cv=none; d=google.com; s=arc-20160816; b=wpDVYXdgaltYxTB7PTx6YkMte2/WcE22o/hnfxyJdrLAi4t2wB2efpLzN5akr+gXFN Cz2ljKkpayz0D1TkKswQztPFs1RiE9k3eK0cBJ74vi6LB/OaIjEULL45uUDTvd1tln6a 0xWGhKL/QVXKFjTPSqVFsH5LvHq/FWPJG6alpDydouwNNcJGYlB7wKobhxKyY/PtQB+S EV2bo6RPjR6/nNEzVqrvW62cRRVaZT3pF1GZ747sOz5sC8QOcMCZjLRinJmQycv0kvzs sSmQ5ZpBRST6NC9xu+s1szF2nmbR7HgzGVtiXotJ2WlLYTpTH55fTYNt6/2RRcms3CjL IPUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:dkim-signature; bh=p0FWXCKCczz2Bu5Sk9jGlAaHu/7LD8eIMRDl+2ywL8A=; b=KamPq5zxaaJ60AJ/f4qFmSRHf+XiZ4eWpohddCn9hq/OEFIX3X6kRZsfho45tcIvEa J+zYfl/NXyM9sOanzyyX7atk0JrMUaY7acXtwAx+nfxuZKZA9R1gbsP90GINP3OuoJ5T 2c4nhuATFbLli+85OT9SKUOtChxwNQeC2FVJd8KHTXYiGdV+ocBUz0gzTDitHc0W+yF4 YXShbb9I1FwPwuXf6lPTBUq6hmMwBPDTuqdJoBJykKVxV7QcfpoULgaHKyKRu2JyEAqT KBc17tMoq4FlOJ4IDrWl06spS9rp78nV+MqV3w4SD2dwxuCz/D5tEJGqzxH0PEJiQ5Vo XCEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TNHidC4n; 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 e12-20020a170902784c00b0014f18b7f047si10642035pln.275.2022.02.28.12.31.56; Mon, 28 Feb 2022 12:32:12 -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=TNHidC4n; 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 S229495AbiB1Ubs (ORCPT + 99 others); Mon, 28 Feb 2022 15:31:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229480AbiB1Ubq (ORCPT ); Mon, 28 Feb 2022 15:31:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 482EF13D7E for ; Mon, 28 Feb 2022 12:31:07 -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 DC22960C95 for ; Mon, 28 Feb 2022 20:31:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 090E8C36AE2; Mon, 28 Feb 2022 20:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646080266; bh=zsRjDMSjqdrecF0uQGK53RtaJnJbg2cIMw159uLcH/4=; h=In-Reply-To:References:Date:From:To:Cc:Subject:From; b=TNHidC4nRa4lVBOlnn6tRGQQuV2FY1QmuuKHcFSzdPuJYPImuOfiCnSw8tIsTi0/1 CB4pHgu6TKDwzbi6gYcRH/5n0ucsTM2Q/uA5PeZWRgAoNj/u1QXO2jzstfKEIxLurk +a9c6DxmoTOam0L1LZD0nugBeDGH4aa1QbjWuJkGuCezADIqIgWqZLfUx4x4NrAJgF HfqZ4YHjJEas1B3CiT+8nLAVp7nYPCE6ci7OATgZTZYINfiiqAz2vApMgDzMLF3hFH Udisi3mVHUw3LTkuIXhVbFKA8ydZjm0UuWFADoLofteyggP/W2VsOnYg1c4sLj7P2X rsUp4xA06nKfA== Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailauth.nyi.internal (Postfix) with ESMTP id 9494827C0054; Mon, 28 Feb 2022 15:31:03 -0500 (EST) Received: from imap48 ([10.202.2.98]) by compute5.internal (MEProxy); Mon, 28 Feb 2022 15:31:03 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvvddruddttddgudefiecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedftehn ugihucfnuhhtohhmihhrshhkihdfuceolhhuthhosehkvghrnhgvlhdrohhrgheqnecugg ftrfgrthhtvghrnheptdfhheettddvtedvtedugfeuuefhtddugedvleevleefvdetleff gfefvdekgeefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprghnugihodhmvghsmhhtphgruhhthhhpvghrshhonhgrlhhithihqdduudeiudek heeifedvqddvieefudeiiedtkedqlhhuthhopeepkhgvrhhnvghlrdhorhhgsehlihhnuh igrdhluhhtohdruhhs X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 161F021E006E; Mon, 28 Feb 2022 15:31:02 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-4778-g14fba9972e-fm-20220217.001-g14fba997 Mime-Version: 1.0 Message-Id: <5a792e77-0072-4ded-9f89-e7fcc7f7a1d6@www.fastmail.com> In-Reply-To: References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> <8f96c2a6-9c03-f97a-df52-73ffc1d87957@intel.com> <357664de-b089-4617-99d1-de5098953c80@www.fastmail.com> <8e36f20723ca175db49ed3cc73e42e8aa28d2615.camel@intel.com> <9d664c91-2116-42cc-ef8d-e6d236de43d0@kernel.org> Date: Mon, 28 Feb 2022 12:30:41 -0800 From: "Andy Lutomirski" To: "Mike Rapoport" Cc: "Rick P Edgecombe" , "Cyrill Gorcunov" , "Balbir Singh" , "H. Peter Anvin" , "Eugene Syromiatnikov" , "Peter Zijlstra (Intel)" , "Randy Dunlap" , "Kees Cook" , "Dmitry Safonov" <0x7f454c46@gmail.com>, "Dave Hansen" , "Kirill A. Shutemov" , "Eranian, Stephane" , "linux-mm@kvack.org" , "Adrian Reber" , "Florian Weimer" , "Nadav Amit" , "Jann Horn" , "Andrei Vagin" , "linux-arch@vger.kernel.org" , "kcc@google.com" , "Borislav Petkov" , "Oleg Nesterov" , "H.J. Lu" , "Pavel Machek" , "linux-doc@vger.kernel.org" , "Arnd Bergmann" , "Moreira, Joao" , "Thomas Gleixner" , "Mike Kravetz" , "the arch/x86 maintainers" , "Weijiang Yang" , "Dave Martin" , "john.allen@amd.com" , "Ingo Molnar" , "Dave Hansen" , "Jonathan Corbet" , "Linux Kernel Mailing List" , "Linux API" , "Shankar, Ravi V" Subject: Re: [PATCH 00/35] Shadow stacks for userspace Content-Type: text/plain X-Spam-Status: No, score=-7.5 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,T_SCC_BODY_TEXT_LINE 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, Feb 28, 2022, at 12:27 PM, Mike Rapoport wrote: > On Wed, Feb 09, 2022 at 06:37:53PM -0800, Andy Lutomirski wrote: >> On 2/8/22 18:18, Edgecombe, Rick P wrote: >> > On Tue, 2022-02-08 at 20:02 +0300, Cyrill Gorcunov wrote: >> > >> > Still wrapping my head around the CRIU save and restore steps, but >> > another general approach might be to give ptrace the ability to >> > temporarily pause/resume/set CET enablement and SSP for a stopped >> > thread. Then injected code doesn't need to jump through any hoops or >> > possibly run into road blocks. I'm not sure how much this opens things >> > up if the thread has to be stopped... >> >> Hmm, that's maybe not insane. >> >> An alternative would be to add a bona fide ptrace call-a-function mechanism. >> I can think of two potentially usable variants: >> >> 1. Straight call. PTRACE_CALL_FUNCTION(addr) just emulates CALL addr, >> shadow stack push and all. >> >> 2. Signal-style. PTRACE_CALL_FUNCTION_SIGFRAME injects an actual signal >> frame just like a real signal is being delivered with the specified handler. >> There could be a variant to opt-in to also using a specified altstack and >> altshadowstack. > > Using ptrace() will not solve CRIU's issue with sigreturn because sigreturn > is called from the victim context rather than from the criu process that > controls the dump and uses ptrace(). I'm not sure I follow. > > Even with the current shadow stack interface Rick proposed, CRIU can restore > the victim using ptrace without any additional knobs, but we loose an > important ability to "self-cure" the victim from the parasite in case > anything goes wrong with criu control process. > > Moreover, the issue with backward compatibility is not with ptrace but with > sigreturn and it seems that criu is not its only user. So we need an ability for a tracer to cause the tracee to call a function and to return successfully. Apparently a gdb branch can already do this with shstk, and my PTRACE_CALL_FUNCTION_SIGFRAME should also do the trick. I don't see why we need a sigretur-but-dont-verify -- we just need this mechanism to create a frame such that sigreturn actually works. --Andy