Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp3809820pxm; Tue, 1 Mar 2022 05:58:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrK9ocPghuqpdjchE760N+wkN1XlbaFX6NJ370Zd56qbw2sjTUa39INFBeYnGZ2sXgv1FQ X-Received: by 2002:a17:90b:3d02:b0:1bc:85fa:e24 with SMTP id pt2-20020a17090b3d0200b001bc85fa0e24mr21907082pjb.239.1646143103714; Tue, 01 Mar 2022 05:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646143103; cv=none; d=google.com; s=arc-20160816; b=XNCWyUcha9N94sdG2dse6hVPbo4V35v0RsmCMUT0PjZnk72ZQ6GlcsS2gMrDUDFgPn JJRrJyVlWFVukPocMAQzSzHVOaugp1nncVGEopICLuyRaonH/1NLyUIbF13v1HnPrSqf v05+iuyHmKJMTrBD4NQmVMEZi8Qw/5YPtogsMnyPpHGPFOfoibSuWMJ/sW4SyQ70I2OX jSNPurKMtsMSsqSJMn0eu+EQ8jGtqPq/q39bWrVEQSV0rF1W4yrZVQ+FrqfXe4khc2wn UpSNzJQLdOBFIDXP7f/8tQ3ZE1sW8VIIFpbv+xG3yvVKUfgTwGU27Nswre+jynDqwr6y roNw== 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=8DT/EMq+vuR64qNtAsWRl0h6VPUS/oJjc/hAgBGsIGU=; b=PM+VwQOTPhiCwxwe0q+Ip1X3Miv5JtpD92QpSdaJgGr3SCmT1ZocFmTzi6QZmHbIOF /6pVjxxjOsKmHB8CghXLrbqXIge29iW4xGdMDRcjclN3RKEdqvVE7MGEvrY/GwtLpj8y m3KaZWI+S3uCWMex1dWgBM3tseln/DKEvgWifZ5oOaPBRhb9pti01iV5VscVSXfW+GZo Qm7MTIBJJ5Z4/qYUsvqTIvlfz5bKx7K6mJzAzOhhKysrExakd5VaosHKtm8/IOa1iasy vkHvQX6iTvuWj2TwatLXm7ihlb2PAaUSAchKdwwPweWYpGYVExDjXSUOs9UOFFNHDXvF VfXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pphtXXaY; 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 d19-20020a631d53000000b00372edd40f78si12933425pgm.386.2022.03.01.05.58.06; Tue, 01 Mar 2022 05:58:23 -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=pphtXXaY; 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 S233160AbiCANm7 (ORCPT + 99 others); Tue, 1 Mar 2022 08:42:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231405AbiCANm4 (ORCPT ); Tue, 1 Mar 2022 08:42:56 -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 17FB29E570; Tue, 1 Mar 2022 05:42:16 -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 A724B614BE; Tue, 1 Mar 2022 13:42:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3198BC340EE; Tue, 1 Mar 2022 13:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646142135; bh=ahSjw3wUn+GFCyQQGsdDHtb34Vw6ym0H5q7SQRteiiw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pphtXXaYXAEqYxD+yk4J7znj4oPZ91A3EQyAzDLIPaJC7UvL0Rkkr/3Z8Z2JRG04k rsOleTpwHny0atwv3QLAcnGH1JWUqHdMH35APN6XPxhev5hxyDc4q84DchtZXsCAjI l9Pqxc1NZy538yFGrCYUfHYO3MWrLRLaNXTtLbsKG2cPcuMDbsf92Cz3RP0ebXhHtA 1QTucIgBE49sYJhhDx92w5duKGAhGhzzorbgIzheX33wb/7qq+72ZJRpbU6LU8KI4d PIF/fHg0v9TaG2heaG/4KHNIuhi0zKg8gvaphzGurLWKb3tQFIAe02Itqyo9tipyOP g5hZb8oDoafsQ== Date: Tue, 1 Mar 2022 14:42:58 +0100 From: Jarkko Sakkinen To: Dave Hansen Cc: "Dhanraj, Vijay" , "Chatre, Reinette" , "dave.hansen@linux.intel.com" , "tglx@linutronix.de" , "bp@alien8.de" , "Lutomirski, Andy" , "mingo@redhat.com" , "linux-sgx@vger.kernel.org" , "x86@kernel.org" , "Christopherson,, Sean" , "Huang, Kai" , "Zhang, Cathy" , "Xing, Cedric" , "Huang, Haitao" , "Shanahan, Mark" , "hpa@zytor.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V2 16/32] x86/sgx: Support restricting of enclave page permissions Message-ID: References: <4ce06608b5351f65f4e6bc6fc87c88a71215a2e7.1644274683.git.reinette.chatre@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.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 Tue, Mar 01, 2022 at 02:26:48PM +0100, Jarkko Sakkinen wrote: > On Mon, Feb 28, 2022 at 07:16:22AM -0800, Dave Hansen wrote: > > On 2/28/22 04:24, Jarkko Sakkinen wrote: > > >> Regarding the recent update of splitting the page permissions change > > >> request into two IOCTLS (RELAX and RESTRICT), can we combine them into > > >> one? That is, revert to how it was done in the v1 version? > > > They are logically separate complex functionalities: > > > > > > 1. "restrict" calls EMODPR and requires EACCEPT > > > 2. "relax" increases permissions up to vetted ("EADD") and could be > > > combined with EMODPE called inside enclave. > > > > It would be great to have a _slightly_ better justification than that. > > Existing permission interfaces like chmod or mprotect() don't have this > > asymmetry. > > > > I think you're saying that the underlying hardware implementation is > > asymmetric, so the interface should be too. I don't find that argument > > very convincing. If the hardware interface is arcane and we can make it > > look more sane in the ioctl() layer, we should that, asymmetry or not. > > That is my argument, yes. > > > If we can't make it any more sane, let's say why the ioctl() must or > > should be asymmetric. > > Perhaps underling this asymmetry in kdoc would be enough. > > > The SGX2 page permission mechanism is horribly counter intuitive. > > *Everybody* that looks at it thinks that it's wrong. That means that we > > have a lot of work ahead of us to explain the interfaces that get > > layered on top. > > I fully agree on this :-) > > With EACCEPTCOPY (kudos to Mark S. for reminding me of this version of > EACCEPT @ chat.enarx.dev) it is possible to make R and RX pages but > obviously new RX pages are now out of the picture: > > > /* > * Adding a regular page that is architecturally allowed to only > * be created with RW permissions. > * TBD: Interface with user space policy to support max permissions > * of RWX. > */ > prot = PROT_READ | PROT_WRITE; > encl_page->vm_run_prot_bits = calc_vm_prot_bits(prot, 0); > encl_page->vm_max_prot_bits = encl_page->vm_run_prot_bits; > > If that TBD is left out to the final version the page augmentation has a > risk of a API bottleneck, and that risk can realize then also in the page > permission ioctls. > > I.e. now any review comment is based on not fully known territory, we have > one known unknown, and some unknown unknowns from unpredictable effect to > future API changes. I think the best way to move forward would be to do EAUG's explicitly with an ioctl that could also include secinfo for permissions. Then you can easily do the rest with EACCEPTCOPY inside the enclave. Putting EAUG to the #PF handler and implicitly call it just too flakky and hard to make deterministic for e.g. JIT compiler in our use case (not to mention that JIT is not possible at all because inability to do RX pages). BR, Jarkko