Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1593659pxb; Tue, 8 Feb 2022 23:28:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJy9N2XSI1AshwlUHiSt1UaeBRalPfcgBD5e4mB5vZ/bQ9s5ait21CaSw/6hZ+3OmZVTNQWd X-Received: by 2002:a17:902:f685:: with SMTP id l5mr914099plg.66.1644391706260; Tue, 08 Feb 2022 23:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644391706; cv=none; d=google.com; s=arc-20160816; b=uB42LKAsLQGnSrLZVHcxa0c9ejJzz+HHfOGJqOjnNtTsDs3mnapeR7T2vVZ9Fzx/Vr 0Aba1p2xw5iGikWEkFpbmh2GBVbWa1lwDgsW2m8aX3fmjrOH/0aohIHpJpVfvcxtBBFC g/sA1USWi2VXuvcupNL6UsMlEb1XFwMKdxSwzqZ4qX/AQCoDphxmnTCLu5YrbnguETGL yZFwjIpDesYBuxs4ZWfrvGeJFxxz4EhLTjio+CVQXPCnX7WyM7ZRpfcmGpJ4Jm+vwRHb 3IjnDVbIfIEX8F4gr8RGsMJCgCTABwGAZMAG8eWmU+op2qTFz5AKQbmgQvD+X3rWiWGa ac/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=H8i2s4xHp0rxY84LN1BxRLDP7j4EYhoJJT+IslnvpoI=; b=b5PZWSETaWVuOmb5D0ipZCJ2LUnrBvAjTI6E24br0RcOC54/4T9vbxasChUzkX8YXp zWfJYSKjhrYvRSqBvIE15yW45w9x8VIvTCY6F32ISrX1IMT7gyR7DYaxnbbM3XRtMhng vjAeSLp0/WK8e2tp+/AQ0IfHFrAUJyz4R2vzUs/sTaumC7E7I5nKCDYxnQgcm8cnlrsr Eqc2FgvCmDa1FRDFM60PdkHbNtVj7weBEND+gC7Jl0/JsAU9ZZlyUJMPuQv73QGCivNl 61D2TwCk5WT9goUPs4737ICVNtoCuNE3ujgXoftvbdZsvE7936dpbiSRVOkSDfK70VVA 3LTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=CeAOjWIQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r188si14941643pgr.231.2022.02.08.23.28.13; Tue, 08 Feb 2022 23:28:26 -0800 (PST) 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=@gmail.com header.s=20210112 header.b=CeAOjWIQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383663AbiBHRCl (ORCPT + 99 others); Tue, 8 Feb 2022 12:02:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231365AbiBHRCh (ORCPT ); Tue, 8 Feb 2022 12:02:37 -0500 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 774CBC061576; Tue, 8 Feb 2022 09:02:36 -0800 (PST) Received: by mail-lf1-x132.google.com with SMTP id 13so975306lfp.7; Tue, 08 Feb 2022 09:02:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=H8i2s4xHp0rxY84LN1BxRLDP7j4EYhoJJT+IslnvpoI=; b=CeAOjWIQeZbI3marhQ90i70bJhrQHxUVRvRhMaA7tO26fi3eAnnwdrAiiS300jSV9/ rFSHN4hYn1DFUV+ovphjx0xXDwujZlMu41W0cY9mh9STuL/ULgRD/Wpc6FL3E9W0MB9n jLShmsInPn/dCkb+n4MWvEH945FHvrOMejxdZhgHNF4js4UR2qDQTn/K6X8YvUU6bh2J CwADrvNHkjsZ90nrYWTIqhYSWrZTmKNZqq+w8ZDD1jbFN//e4zhAc83dzLx+Gq7+0Umg +DTbBao0meb6h15uFR49pmkJHnipUI1jYORJOXulRakWI6MK3fRCNb6YAeKE4+WTCV/V isYA== 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:user-agent; bh=H8i2s4xHp0rxY84LN1BxRLDP7j4EYhoJJT+IslnvpoI=; b=x24ylxJJPbDZ3UksW3/C9ZX5TLB5h/rB3Or+0367mT6F3eefU2y1wu7eOc7kdUWBY1 i+1V6z9qI/HOO1rBlbSLUfaouRZkKe2J1FGM2DMAaxdbm4949mHm/R/oPsURALofY/XZ 8rBcuHVrsk3xJlKUh11cQhxEE7S4/DvhLBK7s0bGGnpqoewmVLEXqnyur+FOYe9nLTY9 wqUNp1Up76f0Xh2G2MgRyjLzoadI6mbxR4M+rl9KgZyxTR37HhWOaPrLjwqnrlIFNFHm 7eDKXI+quol1YOAJrH/160x9nDs9E9YBHRFOetvAXfSU0KaUZOuXVIsRRSZyMEIBlW8q oEiA== X-Gm-Message-State: AOAM530KjF306tVkKAZgHCfUTFL4YvxvypjGdpiLgM3dwbnAtObDvOK0 SfZIVMWE88Ai93/Ziqpsny0= X-Received: by 2002:a05:6512:33c8:: with SMTP id d8mr3533852lfg.41.1644339754685; Tue, 08 Feb 2022 09:02:34 -0800 (PST) Received: from grain.localdomain ([5.18.251.97]) by smtp.gmail.com with ESMTPSA id a12sm643118lfu.162.2022.02.08.09.02.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 09:02:33 -0800 (PST) Received: by grain.localdomain (Postfix, from userid 1000) id 80F685A0020; Tue, 8 Feb 2022 20:02:32 +0300 (MSK) Date: Tue, 8 Feb 2022 20:02:32 +0300 From: Cyrill Gorcunov To: Andy Lutomirski Cc: Mike Rapoport , Dave Hansen , Adrian Reber , Rick P Edgecombe , the arch/x86 maintainers , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , Linux Kernel Mailing List , linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , "Peter Zijlstra (Intel)" , Randy Dunlap , "Shankar, Ravi V" , Dave Martin , Weijiang Yang , "Kirill A. Shutemov" , "Moreira, Joao" , "john.allen@amd.com" , "kcc@google.com" , "Eranian, Stephane" , Andrei Vagin , Dmitry Safonov <0x7f454c46@gmail.com> Subject: Re: [PATCH 00/35] Shadow stacks for userspace Message-ID: References: <20220130211838.8382-1-rick.p.edgecombe@intel.com> <8f96c2a6-9c03-f97a-df52-73ffc1d87957@intel.com> <357664de-b089-4617-99d1-de5098953c80@www.fastmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <357664de-b089-4617-99d1-de5098953c80@www.fastmail.com> User-Agent: Mutt/2.0.7 (2021-05-04) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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 Tue, Feb 08, 2022 at 08:21:20AM -0800, Andy Lutomirski wrote: > >> But such a knob will immediately reduce the security value of the entire > >> thing, and I don't have good ideas how to deal with it :( > > > > Probably a kind of latch in the task_struct which would trigger off once > > returt to a different address happened, thus we would be able to jump inside > > paratite code. Of course such trigger should be available under proper > > capability only. > > I'm not fully in touch with how parasite, etc works. Are we talking about save or restore? We use parasite code in question during checkpoint phase as far as I remember. push addr/lret trick is used to run "injected" code (code injection itself is done via ptrace) in compat mode at least. Dima, Andrei, I didn't look into this code for years already, do we still need to support compat mode at all? > If it's restore, what exactly does CRIU need to do? Is it just that CRIU needs to return > out from its resume code into the to-be-resumed program without tripping CET? Would it > be acceptable for CRIU to require that at least one shstk slot be free at save time? > Or do we need a mechanism to atomically switch to a completely full shadow stack at resume? > > Off the top of my head, a sigreturn (or sigreturn-like mechanism) that is intended for > use for altshadowstack could safely verify a token on the altshdowstack, possibly > compare to something in ucontext (or not -- this isn't clearly necessary) and switch > back to the previous stack. CRIU could use that too. Obviously CRIU will need a way > to populate the relevant stacks, but WRUSS can be used for that, and I think this > is a fundamental requirement for CRIU -- CRIU restore absolutely needs a way to write > the saved shadow stack data into the shadow stack. > > So I think the only special capability that CRIU really needs is WRUSS, and > we need to wire that up anyway. Thanks for these notes, Andy! I can't provide any sane answer here since didn't read tech spec for this feature yet :-)