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 5FEA7C433FE for ; Tue, 8 Feb 2022 17:02:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A91EB6B0073; Tue, 8 Feb 2022 12:02:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A40736B0075; Tue, 8 Feb 2022 12:02:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E29D6B0078; Tue, 8 Feb 2022 12:02:37 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0236.hostedemail.com [216.40.44.236]) by kanga.kvack.org (Postfix) with ESMTP id 802706B0073 for ; Tue, 8 Feb 2022 12:02:37 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3A4B2181C966E for ; Tue, 8 Feb 2022 17:02:37 +0000 (UTC) X-FDA: 79120231554.21.DF47DE6 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by imf14.hostedemail.com (Postfix) with ESMTP id 7591310000F for ; Tue, 8 Feb 2022 17:02:36 +0000 (UTC) Received: by mail-lf1-f54.google.com with SMTP id i34so34624324lfv.2 for ; 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=rQ3v18K2MxjuH+jr6E7nV3PgTc3vfLPgHU6MWfo/6WLqkEGU7RYOwq1ycj4KGmPUtT FM4ge2uXTbR32mH7fYOHd6BW91zxFGHxFCjybodgfciFG6kPgeh8cwo1aJx4UcSQZxqM gbkVAAPEicA6QwePjI+sUWnKH8BRlotZf08ONXMuEll+HF5K82wQMnWuvcvCPmjkvjFA CF4odyA5+SfTjxcqbsNcb2M4hyGxFJ9k5ofwywxLRC5YlWMyyl4yDJA8eoM8otNjjbEu zHxuYwy8HtrUOOAdd3tAziVcT0nxDLPJuwymr9CC3m+M4xamd0stuuCUocfVwdeL+/Cy 940w== X-Gm-Message-State: AOAM533Sm9dUoFolHVSJXUB5YV2P2dRwb0n019DWRHAkYZlL2pNd3IVb jfxRcvKpQEHrG83gAfZ+Pps= X-Google-Smtp-Source: ABdhPJy4vAOsUuMcyywyagL71dLBFChw5CtMbZ5KClivwczQn/i8XjekNjbmQlZlpAVvbRy7btJhpg== 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) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=CeAOjWIQ; spf=pass (imf14.hostedemail.com: domain of gorcunov@gmail.com designates 209.85.167.54 as permitted sender) smtp.mailfrom=gorcunov@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Stat-Signature: qim33kx5zdxipgn3if58aucq1w9fkp4z X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 7591310000F X-Rspam-User: X-HE-Tag: 1644339756-405372 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 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 :-)