Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp927810pxb; Fri, 22 Apr 2022 14:32:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzE/rGepoh/nqBz+gLm4I2r1HZx5ZbUwuzOARk5isFs0nBQRcBvRhs+jkz3HsyUnPLT4oZW X-Received: by 2002:a17:902:ecd0:b0:159:572:af3a with SMTP id a16-20020a170902ecd000b001590572af3amr6607156plh.77.1650663175646; Fri, 22 Apr 2022 14:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650663175; cv=none; d=google.com; s=arc-20160816; b=zcjPhuRQjuwCtGRb5uUJWOa3PS9ekjY63IganJY5ET08pTlDITwwR+HhmqY0qrC5Nk /6DV1GmWRcq5gwhm3eYPUgJGcpCHNOh0qv/CcErKw4AabCR3v4mVyTaowZ+jvJymiPJw JSKqug7wK7cSM5mDw3+gxbxF4mwPT8/2sL16QPREw9kstjG1UmmZrWMiZk3yhzFg7tiV a1dDczpvlykuN64z8lm5tHax5mD9eeBhDgzkjUGYOmFi9Jc1PjT/jU2HX7+C4PWnUHcd QQfyHP+s8Gx+RPHaET2BZgZgkBBZfArHxLDflCjoLvcNaY08ayoiUIzKuxt4mAWXin+F e5UA== 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=AIt3Wx1sGfLckKnq/6ufCPe8c1tMjXMkmUsoaEi5j2w=; b=hjDWxXlQV+NX8Q0KKauHStSQmOCsIitg4bOPx5FVrTeP8EhVhUAiMSYxAenPAXPdie N1zhN/SxIQO2UzAJD9aLxttiDwzuioV6AiQ//ht9Sq8Ri3tRKoLC+aj4ec/MjLxVdCHr 2Zmo2LFPDDuCU/HqXhbfjqVlfdZp870HcRl62eDUgE9Eo8PN8Aludom+bS8Yizk1jAj7 yro4q8jvRhPlrxWAtqiy8O8Xh2LKqtU5bUJNJxTVWkYuIM7tbqrWU/Z8Ti0H7tH/me4k ZroBvqn/7MLptFP3lJxfwAqOD6hKHDa+BxzrTH49QEFy8v19+eVovpZRJCw8DOSxb47q /Kbg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oNyJNZZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id a8-20020a17090abe0800b001cb475fa87bsi8184330pjs.116.2022.04.22.14.32.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 14:32:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oNyJNZZ2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D2AF42EEAC4; Fri, 22 Apr 2022 12:40:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233605AbiDVJVa (ORCPT + 99 others); Fri, 22 Apr 2022 05:21:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1446019AbiDVJUx (ORCPT ); Fri, 22 Apr 2022 05:20:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E6FB53E2C; Fri, 22 Apr 2022 02:17:36 -0700 (PDT) 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 AF75460FC1; Fri, 22 Apr 2022 09:17:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A3C4C385A0; Fri, 22 Apr 2022 09:17:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650619055; bh=iqCW7A6ZXIeIMzwpuEVmkMyobtqwXfhGzomkPzFjfhA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oNyJNZZ2f5Ve8HItc27uvfdt3nih+W6bsvDgzMBWo8zE92p1KCOXIFpmCO/yk2svr NeDzJCdc/qS4/GEQCLNaC9yLTLv2myCkq8pA6wY7MRjfLUhE+PZAbAuXFBLSCVxlXm CyRy3JBcN7xJlS+MYxgOyE0/32HEGtb5gyyXHiIPp7zqEmay59irQ+/qwVPebIvhKw wLH5/fYjGIZA4J0flSM8YFy/Ba90ANoJMHpN+m4mE//7t/a8QDB84F8f3IPqJm1SEf e98HDEpi+VxXtnkRYp9kVWhyH7KvTSLoalr8WdYtDVGQ49RXSKdArdPp7mHvir2tjJ RtA1svfSZCzqg== Date: Fri, 22 Apr 2022 12:16:19 +0300 From: Jarkko Sakkinen To: Reinette Chatre Cc: "Dhanraj, Vijay" , "dave.hansen@linux.intel.com" , "tglx@linutronix.de" , "bp@alien8.de" , "Lutomirski, Andy" , "mingo@redhat.com" , "linux-sgx@vger.kernel.org" , "x86@kernel.org" , "shuah@kernel.org" , "linux-kselftest@vger.kernel.org" , "Shanahan, Mark" , "Christopherson,, Sean" , "Huang, Kai" , "Zhang, Cathy" , "Xing, Cedric" , "Huang, Haitao" , "hpa@zytor.com" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH V4 00/31] x86/sgx and selftests/sgx: Support SGX2 Message-ID: References: <2f4338f37943c2b067db16ae65c9af665d3b51d9.camel@kernel.org> <9fbf26c8-5808-20c5-8653-d4f36bf398a4@intel.com> <42a52a6018e8dadb4c3eebefaae4dab31c0d5721.camel@kernel.org> <54f053d8bb6b72725b2351fc2016d20b65cebbf1.camel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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 Thu, Apr 21, 2022 at 08:29:31PM -0700, Reinette Chatre wrote: > Hi Vijay and Mark, > > On 4/21/2022 4:46 PM, Dhanraj, Vijay wrote: > > Hi All, > > > > I evaluated V4 patch changes with Gramine and ran into an issue when trying to set EPC page permission to PROT_NONE. It looks like with V3 patch series a change was introduced which requires kernel to have at least R permission when calling RESTRICT IOCTL. This change was done under the assumption that EPCM requires at least R permission for EMODPE/EACCEPT to succeed. But when testing with V2 version, EACCEPT worked fine with page permission set to PROT_NONE. > > > > Thanks to @Shanahan, Mark for confirming that EPCM does not need to have R value to allow EACCEPT or EMODPE. Given this, can we please revert this change? > > > > Thank you very much for pointing this out. I can revert the change > to what was done in V2 where the only check is to ensure that W requires R. > This is a requirement of EMODPR. Could you please check if this snippet > results in things working for you again? > > ---8<--- > diff --git a/arch/x86/kernel/cpu/sgx/ioctl.c b/arch/x86/kernel/cpu/sgx/ioctl.c > index 83674d054c13..7c7c8a61196e 100644 > --- a/arch/x86/kernel/cpu/sgx/ioctl.c > +++ b/arch/x86/kernel/cpu/sgx/ioctl.c > @@ -855,12 +855,8 @@ static long sgx_ioc_enclave_restrict_permissions(struct sgx_encl *encl, > if (params.permissions & ~SGX_SECINFO_PERMISSION_MASK) > return -EINVAL; > > - /* > - * Read access is required for the enclave to be able to use the page. > - * SGX instructions like ENCLU[EMODPE] and ENCLU[EACCEPT] require > - * read access. > - */ > - if (!(params.permissions & SGX_SECINFO_R)) > + if ((params.permissions & SGX_SECINFO_W) && > + !(params.permissions & SGX_SECINFO_R)) > return -EINVAL; > > if (params.result || params.count) Just adding that it's fine for me to revert this. BR, Jarkko