Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2801086imu; Fri, 23 Nov 2018 15:07:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/WoB7VgfgstPot6CLKcgwlIl/0h2XthRIK/mhdEyh0KZYNeZV1yxwnijmc9KZnDXuhVAUec X-Received: by 2002:a63:374e:: with SMTP id g14mr16144167pgn.59.1543014465181; Fri, 23 Nov 2018 15:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543014465; cv=none; d=google.com; s=arc-20160816; b=cHVIFcCIFNt0U5S+8Of4zhe4Roa1/hX11B1ykoHoHiPQgvYKEz8DuMhnnwvT3R1Uh5 kn+wJvZL1OtNEKIYvxhfYvzr8xCCV1HQ1aD4u2P3kc7aIbKSA08n62XCh7furpePLPVO GI+rasAANpGGWfAl2Oz4/Vpr+Tkyg+pCJ+ltQF4/7/Pg+9dzLVyuobykFq6dGeYGGdNG 1P50dwhi7KsFTUuBwRjkX39Yi7Fse2Y+/TNyZYEKxqcrVSpvDD7lc4zb1OwbTmcZTh/Y orb2MwqLbHv6Qb5MyW2ToWHeLMkxbTnfanPooFznKU8YnxDDKH1D777j6l4I/3mgNb4Y IqCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sZe18ni8qJPlyeXERKTjS6uxeH4f4DT0dCFldudIe0g=; b=wQVVJPLZofS3DjpfLxxUUXqqCtaajkW3mmyLNGrJYGcf2ONWJTtBgQKICbMpXE8k1X FuGOqr1rDVyFvB9p5yDGzllomaOSY4pTzjw+G6rRAKH2UlZHGyEqSXbXT7/oS1DnOHfY QqaG331JbMqkIz67Mi6Ef1azMg3rGm2SVKKkP0xTV9VBHYpuR8YJtXpsJNTE+8WDjdRn oqfjbrqKX2LD1JyGO8IVYcURG2VCimJCL1jRA8dkmm5/URI+9Rfyz5HKwmGi4oGH9xFX EuqjmS4WFg+udMik0R8eebrzxNkHqXgcVRnIW2yv+jJ0Hz9tQY8JVIc15wyehtSpLgeA ZkpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Kb7I+zM1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si6787474pla.173.2018.11.23.15.07.30; Fri, 23 Nov 2018 15:07:45 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Kb7I+zM1; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437676AbeKWCBO (ORCPT + 99 others); Thu, 22 Nov 2018 21:01:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:59528 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437666AbeKWCBO (ORCPT ); Thu, 22 Nov 2018 21:01:14 -0500 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AD08120684 for ; Thu, 22 Nov 2018 15:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1542900085; bh=PrAXY+uvMxQxYzDIlCv87TRxKZFwsa+PgJBBd1NJU6k=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Kb7I+zM12qQonncwjrvDvyC7GCQwuDwh71KAGP65um8BjW21oAAFE5yHOIz+62neV GPk9NLYSB6326G9tC+iNQ0mJ2amDqTtA/rUHqHJOQ7nXxImzNhU5tsbwNCclu++cQ9 hea55gXbgKLong7ftu7upGdRLqKqc/vus7++SV+U= Received: by mail-wm1-f51.google.com with SMTP id k198so9507572wmd.3 for ; Thu, 22 Nov 2018 07:21:24 -0800 (PST) X-Gm-Message-State: AA+aEWYhfc2MjRMvp10NtR1yB4hk+O8QknDsWMJ0cinc9QjZthDkIf4Y othqP6w5nnhZKmmS0u27Okq2vIE7Kq0eR4FmjBgNgA== X-Received: by 2002:a7b:ce11:: with SMTP id m17mr3561460wmc.74.1542900081182; Thu, 22 Nov 2018 07:21:21 -0800 (PST) MIME-Version: 1.0 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> <20181122111253.GA31150@wind.enjellic.com> In-Reply-To: <20181122111253.GA31150@wind.enjellic.com> From: Andy Lutomirski Date: Thu, 22 Nov 2018 07:21:08 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver To: "Dr. Greg Wettstein" Cc: Jarkko Sakkinen , 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 Shevchenko , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 22, 2018 at 3:12 AM Dr. Greg wrote: > > 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. > It's very nice of Intel to supply source. Also, yikes, they wrote their ME blob in Java? > 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. How do you generate your root of trust for attestation if you don't use Intel's service? If I understand right, Intel's mechanism boils down to Intel possessing something that is functionally equivalent to a list of valid provisioning keys associated with genuine Intel chips. (It could be literal provisioning keys, or keying material from which the provisioning keys are derived, or even public keys for which the private parts are derived from the provisioning keys. But all of this boils down to the CPU, via some enclaves, proving knowledge of the provisioning key that is available when MRSIGNER is Intel. I could imagine replacing this by running Intel's mechanism once to generate a new root of trust for your own mechanism, or even by buying a bunch of CPUs, determining their provisioning keys with MRSIGNER=Dr. Greg, and enrolling those. But I don't see any way to bootstrap an attestation service on a CPU you've never physically possessed without running *something* with MRSIGNER=Intel. > 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. I'm a little bit puzzled by your privacy claims. If an attacker controls the kernel, then the secrets in your enclave may still be secure, but you have very little privacy in terms of trying to prevent the attacker from tying your communication to your physical machine. > 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. I agree, hence my email :) > 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. > Can you explain your use case for a launch enclave? The current driver won't allow you to supply an EINITTOKEN, so I'm not immediately seeing what you would do with a launch token. If you really do need it, I suppose we could have 'unprivileged', 'provisioning', and 'launch' nodes, and maybe even 'launch_and_provision', but that's starting to have some combinatorial issues.