Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1149601pxx; Tue, 27 Oct 2020 09:21:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiBQ4loMakBFMqo7Lsi3NL2pFSa71F+xMykGZLoKI2XHqwkRglr33EM/H5+y799aNRCuBh X-Received: by 2002:a17:906:81c5:: with SMTP id e5mr3097981ejx.10.1603815661178; Tue, 27 Oct 2020 09:21:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603815661; cv=none; d=google.com; s=arc-20160816; b=E+1vcKWMlIHwFY+bH+kA6N48BRNJHgUnIOGHVPZuxghISJhNjgUwA0tqSyC0wsL+4b lXR2kEmbnt0BlfDUmWmYTUH4I3sZYJADuEtg9cwZ32dSMdHiDCQ07xlC/9uEm0j41WyS OfvQw2xvF+5oopTfwNLDBqXnQUSKOyT2ULfGe/bXqHb0cGEjnzyoMWNHRWbKqNLrNhyn 1lffdvIQVYjNcwF7O6lvTDzQaOiZPh6TkXFVJP18Ud5f3w5zaDvoI9w+/DG1a0iZLe3m LS+aQKCvj1D+NsQgwQvr51QqgObnzgHVdtK7/Y8OvahRM9TBzGn6k1asDh5Zcva9dg7z H0Ew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:autocrypt:from :references:cc:to:subject:ironport-sdr:ironport-sdr; bh=pEuFJPjp/UNyZ/xZ+6U/d+iYjk1X1Fu32j+7CEss+rE=; b=oZKqT3SNpz8SEjZGVDg6GaDmcXR0lcoFzjKNsg1ty4XDHhOGjFQYjXrHnOaGcY/kp4 fgInky5j1RYjn1LkQdorRv2BSya1vJ2fE8m2+mothl8jarWZgJIRUshM1VIvh/BkgWJc L4o8PyMol4gmHNu401oYPQ3TmTSgJbC2ha1hpuV8VErx8gHP/EQlgf61N46Tcg12D+AG VjpN/W5YAVCZzDSyAesmL3npOYCbOPvtv9T3WeeaQTFpXH5begZ3Ydx3UbquN8Olyth6 D1aa8ID23fM8VMl2/CU4r1UFj46FfbQ09FpGaAPyBbhdxj7vPsXlC0tehWUCnBlGvhyq 8tOg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u15si1156602edx.510.2020.10.27.09.20.37; Tue, 27 Oct 2020 09:21:01 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1797243AbgJ0PWY (ORCPT + 99 others); Tue, 27 Oct 2020 11:22:24 -0400 Received: from mga05.intel.com ([192.55.52.43]:18882 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754938AbgJ0PUD (ORCPT ); Tue, 27 Oct 2020 11:20:03 -0400 IronPort-SDR: G3uNJYm1xW1vy9p43WCVYmk3MrXYGW3mhyQdg+E+4cbfDlUHh12vcaMBJuJ+BMKRhUOcIdu2+4 qQOMu/ea+dRA== X-IronPort-AV: E=McAfee;i="6000,8403,9786"; a="252799425" X-IronPort-AV: E=Sophos;i="5.77,424,1596524400"; d="scan'208";a="252799425" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 08:20:02 -0700 IronPort-SDR: /G0Ch6MjZIzQeaaQ0a+4oBXwr/iV8PY5rgozNMSQzu/wsB/VEfxQUvBumeWLsmvCo9EQNWWYot gKeedcC0WMiA== X-IronPort-AV: E=Sophos;i="5.77,424,1596524400"; d="scan'208";a="303913005" Received: from junkyupa-mobl.amr.corp.intel.com (HELO [10.213.166.147]) ([10.213.166.147]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2020 08:20:00 -0700 Subject: Re: [PATCH v33 11/21] x86/sgx: Linux Enclave Driver To: Borislav Petkov Cc: Jarkko Sakkinen , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, Jethro Beekman , Haitao Huang , Chunyang Hui , Jordan Hand , Nathaniel McCallum , Seth Moore , Sean Christopherson , Suresh Siddha , akpm@linux-foundation.org, andriy.shevchenko@linux.intel.com, asapek@google.com, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-12-jarkko.sakkinen@linux.intel.com> <20200626153400.GE27151@zn.tnic> <1ada871a-2350-1007-c625-a00bdb0d439b@intel.com> <20201027100515.GA15580@zn.tnic> From: Dave Hansen Autocrypt: addr=dave.hansen@intel.com; keydata= xsFNBE6HMP0BEADIMA3XYkQfF3dwHlj58Yjsc4E5y5G67cfbt8dvaUq2fx1lR0K9h1bOI6fC oAiUXvGAOxPDsB/P6UEOISPpLl5IuYsSwAeZGkdQ5g6m1xq7AlDJQZddhr/1DC/nMVa/2BoY 2UnKuZuSBu7lgOE193+7Uks3416N2hTkyKU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qdl1ugJx9Ymsp8kXKMk9GSfmZpuMQB9c6io1qZc6nW/3TtvK pNGz7KPPtaDzvKA4S5tfrWPnDr7n15AU5vsIZvgMjU42gkbemkjJwP0B1RkifIK60yQqAAlT YZ14P0dIPdIPIlfEPiAWcg5BtLQU4Wg3cNQdpWrCJ1E3m/RIlXy/2Y3YOVVohfSy+4kvvYU3 lXUdPb04UPw4VWwjcVZPg7cgR7Izion61bGHqVqURgSALt2yvHl7cr68NYoFkzbNsGsye9ft M9ozM23JSgMkRylPSXTeh5JIK9pz2+etco3AfLCKtaRVysjvpysukmWMTrx8QnI5Nn5MOlJj 1Ov4/50JY9pXzgIDVSrgy6LYSMc4vKZ3QfCY7ipLRORyalFDF3j5AGCMRENJjHPD6O7bl3Xo 4DzMID+8eucbXxKiNEbs21IqBZbbKdY1GkcEGTE7AnkA3Y6YB7I/j9mQ3hCgm5muJuhM/2Fr OPsw5tV/LmQ5GXH0JQ/TZXWygyRFyyI2FqNTx4WHqUn3yFj8rwTAU1tluRUYyeLy0ayUlKBH ybj0N71vWO936MqP6haFERzuPAIpxj2ezwu0xb1GjTk4ynna6h5GjnKgdfOWoRtoWndMZxbA z5cecg== Message-ID: Date: Tue, 27 Oct 2020 08:20:00 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201027100515.GA15580@zn.tnic> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/27/20 3:05 AM, Borislav Petkov wrote: > On Mon, Oct 26, 2020 at 02:26:13PM -0700, Dave Hansen wrote: >> What were you concerned about here? Was it how long the syscall could >> take, or that one user could exhaust all the enclave memory in one call? > More the latter. And generally, to have a sanity-check on all requests > coming from luserspace. I can't think of a *lot* of spots where we have sanity checks like this for memory. We have cgroups and the overcommit limits. But, in general, folks can allocate as much memory as they want until allocations start to fail. Should SGX be any different? If we had a sanity check that said, "you can only allocate 1/2 of enclave memory", wouldn't that just make somebody mad because they want one big enclave? Or, do you just want a sanity check to see if, up front, the user is asking for more enclave memory than there is on the *whole* system? That's also sane, but it doesn't take overcommit into account. That's why, for instance, we have vm.overcommit_ratio for normal memory. BTW, I think we all agree that a cgroup controller for enclave memory is going to be needed eventually.