Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp58983pxp; Fri, 4 Mar 2022 21:24:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxBs3nESlme5DJblyFhqoDZbhCT3IInHf43+XArESuR10bWrdabqxSg2Ho3ibr+o7rir+Uv X-Received: by 2002:a17:90b:4b0d:b0:1bc:4cdb:ebe3 with SMTP id lx13-20020a17090b4b0d00b001bc4cdbebe3mr2212553pjb.176.1646457853988; Fri, 04 Mar 2022 21:24:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646457853; cv=none; d=google.com; s=arc-20160816; b=cGP9ca3XIGYEaBOkrDkfzHuLpShYE/9oD2TG+hSgeXT2++nZtvhIiXwqwgpzl2EaGp Y5vL8/oqyZ4SigRHKHzkOkQeDALWKUvF6pAtR3ozYgmMOExOjSRs51hKqAmvzQouyQ2T xzMJ5J2vRgOJRQDAZeFGFw4XqxIpMakVKLSh//YXm+VTwgpqb2aMO91cR7bv130OGhNu BJcrhBpj9ZfgskgzJI9jBrgZvR1yAH1GG8qgU2iSKRk4RbquFhB4aqKGDqn/IEESr8J8 cZfT5WVWeEBi7BwhS7knY6BO/XufO0it7SnbkE3ntyDFWWIQ5eMFGixlPuRl+zj3bHNA ldrA== 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=y6Mxatrp1JXIDpOc/z8cGZpcpTxwjfTvQqS/SWEcaIc=; b=lBpSrGLUG2uG9t97mVGXSp8S7GyXUHNrT0JiTGIW794Ei6zC1fdSP2/maU1S3gR9Mo EXOLS/9hnMsRTS2DeOo4in2MyUpAYxDGXF2PItZtQ2wMP9+Zboxk9CVWmSJmolm1eY/q 3wh7UN/UsMU66YNNe50x/H5rf59BjVQhdQgyeHFPZB/SYpFGStVxl2ygtg+coDJNPLZH YlJ8suLrRd4+mptuZXxzcz/70TbrqmmhGZZX9iljJyHZ+yQtUGMdtaUIShxNqZOeqrPy axBkQHH3wLlpXjs6/egcpz1vcg2FGatVKjxQCVtDXEsoKCB/TlKZ2bQvVwlWx1gYhIfj fbkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nl6Srsn9; 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 i8-20020a17090a650800b001bd14e03076si1242268pjj.78.2022.03.04.21.23.57; Fri, 04 Mar 2022 21:24:13 -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=nl6Srsn9; 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 S230411AbiCECBc (ORCPT + 99 others); Fri, 4 Mar 2022 21:01:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229545AbiCECBc (ORCPT ); Fri, 4 Mar 2022 21:01:32 -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 8F2C253730; Fri, 4 Mar 2022 18:00:43 -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 2B69761F69; Sat, 5 Mar 2022 02:00:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 07948C340E9; Sat, 5 Mar 2022 02:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1646445642; bh=teMw15QNNKxcL9BNgZK2e3zh41BE0uafMgfWgTe4aqQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nl6Srsn9BEOlgTsNzAAhTFWkm5wMr50b8QEK3Wo27w+Ls1xIMwxSYRZcHUEaTT0CW cgL8FaNx/NOMw1tP5tgHZHUzpwEyYmrVSUFb8fFA0sdgjCf5ef3waB18bfwBlcwOB2 BjCLPcV+lT2tXM9svFQ8fZoIknGc26HnrLhJUVmwbJlSafC/hldriiumYM+wJuXzNn qaQW2I5nGNLNUSFLUAfrEpnnYTs50s8uvRsm6NvC9DLBL2YN2agPQDeobhdiT03YM5 YeoER4A0Ea48ui4V4eNGil/zzMtUoBYVb9rzTYh6KM6KcZ+eDzJxFDaU6zPWsp2/Ii nS3MDvvMblxAA== Date: Sat, 5 Mar 2022 03:59:56 +0200 From: Jarkko Sakkinen To: Reinette Chatre Cc: linux-sgx@vger.kernel.org, Nathaniel McCallum , Dave Hansen , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , "open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Subject: Re: [PATCH v3] x86/sgx: Do not limit EAUG'd pages by pre-initialization policy Message-ID: References: <20220304033918.361495-1-jarkko@kernel.org> <684930a2-a247-7d5e-90e8-6e80db618c4c@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <684930a2-a247-7d5e-90e8-6e80db618c4c@intel.com> 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 Fri, Mar 04, 2022 at 11:09:36AM -0800, Reinette Chatre wrote: > Hi Jarkko, > > On 3/3/2022 7:39 PM, Jarkko Sakkinen wrote: > > Pre-initialization policy is meant for EADD'd pages because they are > > part of the enclave identity. It's a good practice to not let touch the > > permissions after initialization, and does provide guarantees to e.g. > > LSM's about the enclave. > > I disagree. There are scenarios where it is indeed good practice to > modify the permissions after initialization. For example, pages that > may be used for relocatable code can start with RWX permissions but once > the pages have been populated with the code they should be able to restrict > permissions to RX only. It is not good practice to require RWX permission > over their entire lifetime. Ideally pages should only have the lowest > permissions possible. The only permissions kernel has real control is PTE permissions when the enclave has been initialized. You are introducing an artificial limitation with vm_run_prot_bits that makes e.g. EMODPE more costly for no good reason, and in-kernel variable has nothing to do with the permissions. They are located in EPCM. > Supporting the modification of permissions after initialization enables > the security conscious enclave owner to support the security > principle of least privilege. 1. Kernel has the control of PTE permissions. 2. Enclave has the control of EPCM permissions. vm_run_prot_bits does not help making anything more secure. BR, Jarkko