Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2075420imu; Fri, 23 Nov 2018 04:21:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/XIxN7G9M7GfA855O8Uizz1jz8uD5Zj0KW8m1W/cb+BuQJaddeWyvIgAh+/DucPPJnsScgT X-Received: by 2002:a63:9041:: with SMTP id a62mr13605793pge.163.1542975704554; Fri, 23 Nov 2018 04:21:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542975704; cv=none; d=google.com; s=arc-20160816; b=nTILAm4PW1kkkTgny70t7qZlhztYwGSzkMgNHpu4co2PnJucA4OI0e+Fvm7JJPP/zK FitbYdrRg9kgVDa+Q3w3AnQliFrSKiSGn31CnxJccZ71jhcYvrtgqtlS4Hc7P7m6yKAI 8l82ECHRZxUSz9iGDEjmEYz9rGPHDJXNoIi3Y6+QcTcuWpqmvq8rrwWy83njUg2LDuDx TMDhJYJ8CC8gW8IdGiIDz55Y40kOciyFPsn6tEnXq6DXdH9sBvpL+bpAQ9bbNN72WrjR RLleb0InjOZtSCYVzq+NqjT6fVa7XWkyZUx+e3n/dcSuZqLblOvuCFNnAR0Rq02xtAyO clww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date; bh=XuCFt3GG9F+Eq0kB+zlZDQn0Zu15KqbuMwVx1o6sMvc=; b=l3RYVeKfn1aMLso/FOzSn+MaJvJLTds1FP+uJeDRd/sBU2nlA5jXtnikqeQMjKBcGG 1qPRGB2O1AJy6GusRN57wRdX6y1Ls0qBkW0wG8abxpy7So4gSEnpMztjwyk5FA0lvBVf SxbG4RAjfMbZP9Ju9Nm6VxLJ/7N35d0Ws1M/WOlAA/IrdVL4jxeUlGCLIE4SCE4CdJ27 Xdi3cGb4GVJR44Zlml89+j8aiSLBwc77yt+Hxolevq5xLYHxb4tMQfjOUEMaVxQKzgO3 /K75QtoBFRvBGRwoUYiblKXwF23SBVbG3wIxQhVDoRFIyLj1OC5nOFtJ/yFshI81yifD cI9A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w17si47243073pgl.6.2018.11.23.04.21.29; Fri, 23 Nov 2018 04:21:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388368AbeKVVwg (ORCPT + 99 others); Thu, 22 Nov 2018 16:52:36 -0500 Received: from wind.enjellic.com ([76.10.64.91]:58450 "EHLO wind.enjellic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732060AbeKVVwg (ORCPT ); Thu, 22 Nov 2018 16:52:36 -0500 Received: from wind.enjellic.com (localhost [127.0.0.1]) by wind.enjellic.com (8.14.3/8.14.3) with ESMTP id wAMBCrYk032663; Thu, 22 Nov 2018 05:12:53 -0600 Received: (from greg@localhost) by wind.enjellic.com (8.14.3/8.14.3/Submit) id wAMBCrso032662; Thu, 22 Nov 2018 05:12:53 -0600 Date: Thu, 22 Nov 2018 05:12:53 -0600 From: "Dr. Greg" To: Jarkko Sakkinen Cc: Andy Lutomirski , X86 ML , Platform Driver , linux-sgx@vger.kernel.org, Dave Hansen , "Christopherson, Sean J" , nhorman@redhat.com, npmccallum@redhat.com, "Ayoun, Serge" , shay.katz-zamir@intel.com, haitao.huang@linux.intel.com, Andy Shevchenko , Thomas Gleixner , "Svahn, Kai" , mark.shanahan@intel.com, Suresh Siddha , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , Darren Hart , andy@infradead.org, LKML Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver Message-ID: <20181122111253.GA31150@wind.enjellic.com> Reply-To: "Dr. Greg" References: <20181116010412.23967-1-jarkko.sakkinen@linux.intel.com> <20181116010412.23967-19-jarkko.sakkinen@linux.intel.com> <20181119161917.GF13298@linux.intel.com> <20181120120442.GA22172@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181120120442.GA22172@linux.intel.com> User-Agent: Mutt/1.4i X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.2.3 (wind.enjellic.com [0.0.0.0]); Thu, 22 Nov 2018 05:12:53 -0600 (CST) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 20, 2018 at 02:04:42PM +0200, Jarkko Sakkinen wrote: Good morning to everyone, Happy Thanksgiving to those who are celebrating the holiday. > On Mon, Nov 19, 2018 at 08:59:24AM -0800, Andy Lutomirski wrote: > > The idea here is that, under normal circumstances, provisioning only > > runs once, or at least only runs rarely. So, rather than the SDK > > running provisioning whenever it feels like doing so (which is the > > current behavior, I imagine, although I haven't looked), there would > > be a privileged program, perhaps a systemd unit that runs when needed, > > that produces the key material needed for remote attestation, and > > non-root users that need attestation would get the keying material > > from the provisioning service. And the provisioning service could > > implement its own policy. Ideally, the service wouldn't give the > > sealed keys to users at all but would, instead, just provide the > > entire attestation service over a UNIX socket, which would make > > provisioning capabilities revocable. > > > > Does this make sense? > Yes, it does for me at least now that you brought some context. Let me see if I can add a bit of additional context to the above to frame further discussion regarding two major needs of the driver before it lands. What Andy is describing is how the current system already works. The driver is at the root of a fairly complex eco-system of code, cryptography and protocols that implement SGX functionality. This software stack is known as the SGX Platform SoftWare (PSW) or SGX runtime. The Intel provided runtime is implemented in C++ and, depending on how you count it, clocks in at around 50+ KLOC. All of this ends up as a single 1.8 megabyte binary named aesm_service that links against 35 shared libraries and is run by systemd. This binary implements the functionality needed to load, initialize, run and attest enclaves. It also implements communications with the Intel provisioning and attestation services which is needed to provision a private EPID key to the platform and to verify the status of an enclave attestation quote from a remote platform. In order to achieve the SGX/IAGO security model, a lot of this functionality is implemented by choreographing exchanges between six Intel supplied and signed enclaves. Intel supplies source code to these enclaves and understanding how all of this works requires an understanding of that codebase as well. To top if off there is also a 50K hunk of signed Java bytecode that gets stuffed into the Management Engine if you are interested in platform services. All of the above is what we wrote an independent implementation of, in straight C, that is capable of linking against the MUSL C library with only libelf and OpenSSL as dependencies. We developed all of this to support a reasonably sophisticated multi-enclave SGX security application that implements modeling the runtime behavior of applications running on the Linux kernel. That application uses an alternate enclave attestation and communications architecture that we independently developed. I don't describe the above to hype or promote what we do. Everyone discussing these issues is a professional software engineer or architect. As such, you will know that by the time you get done doing all of the above, to the point where you are willing to take it to Washington, DC to do live technology demonstrations to government agencies with seven minutes of setup time, you are going to have to be pretty confident that you know how all of the pieces are supposed to go together. Based on this experience, if the proposed driver lands in its current state, Linux mainline will have, at least from a privacy perspective, an inferior implementation of SGX. In addition, we are not confident the driver will be useful to anything other then server class hardware and will be incapable of supporting virtually all of the existing SGX hardware in the field. This is NOT a criticism of Jarkko's work or the overall technical implementation and quality of the driver. We actually use and test a modified version of the proposed driver, along with the out of tree driver in our platforms. At a high level, addressing these issues is straight forward. First, the driver needs to support authorization equivalent to that which is implemented in the current Intel Launch Enclave, ie. control over the SGX_FLAGS_PROVISION_KEY attribute. Secondly, the driver needs to drop its prohibition against launch enclaves, ie. returning EINVAL when a request is made to initialize enclaves which have the SGX_FLAGS_EINITTOKEN_KEY attribute set. There will be some devil in the details with respect to both of these issues, but those discussions can follow later. Addressing these two issues will at least create an environment where the proposed in-tree driver is equivalent in privacy and functionality to the out of tree driver. SGX is a remarkably complex piece of machinery. Producing a useful driver requires the consideration of a lot of issues which, in our opinion, have not been fully represented in the discussions to date. > /Jarkko I hope the above is useful for framing future discussions. Have a good remainder of the week. Dr. Greg As always, Dr. G.W. Wettstein, Ph.D. Enjellic Systems Development, LLC. 4206 N. 19th Ave. Specializing in information infra-structure Fargo, ND 58102 development. PH: 701-281-1686 FAX: 701-281-3949 EMAIL: greg@enjellic.com ------------------------------------------------------------------------------ "I suppose that could could happen but he wouldn't know a Galois Field if it kicked him in the nuts." -- Anonymous mathematician Resurrection.