Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3089899ybt; Mon, 29 Jun 2020 15:05:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwa1b5T4hFuGf30XAFcVhBI2yGyMyAXzhm2Q3V0Gft5j9K9hvcsK19itXI/RQ/arcpLkYN4 X-Received: by 2002:a17:906:4086:: with SMTP id u6mr16863425ejj.9.1593468340756; Mon, 29 Jun 2020 15:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593468340; cv=none; d=google.com; s=arc-20160816; b=sYdQWSIBwtQ+PFiz+gxusAm8Nh6OJ035BftOwbzaLebnYL2D+Rmitriiuvj48N5G0Z ZalP0dM8fu93WTvvPosvxQnPCxf/9S+vpd9T46fS1ViEzBr36jSN52ETbfQ/apKgcr/m Oh/Mb6l/ck+0gKcTtINU48HF4pbys8Hrz7Chttfv/G7b+fOFWWDbiTGwLDRVZxfldSHN JU93kPeEQQX7ebBKx+j11K5qfY7tjY14KhmfvKhHePUYQd08YfjRocUw/8hIrVrog8px EW/RoZxMtFVwtjbcLTiVKHsYaDE5JfS7gKHAuUYvD+jsrBK5FgWVjXpXNV8vtkB9FukT +87w== 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:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=C9XgvL1xettBbhieRaA2BiZ15I1ntQAjNh0S6X+Kyw8=; b=SL3M/DILkmG/vHVAb6wU4Agk2z00uCeFFdYHI8fY0WmxUyJGp4lNFElrikZqoORnox CcrtprbLO47CTf4uTkDmbmo0yZRXn5ANrRH021E904e/1VoGzcA5DbVK7+D+3A5X9/Tc f7cCSgernWhvMM+Tkmyhmif2LEa8k273TZ9i3A+uShQNlqUGt2xnKM114M7itiKU89WC Lbzv0I4G4RxHrLs5PGrMcZrZnxuhJ0r8TAIgX5xusmfHXNF2jUKSABSZRWt9Dt8Z3QQV ETIN3DAfUPWyqL7xi+TB3GQow5SMGPayRZTK4V/dEzIpcfjyv2uh6mE5yH8D1eoZ2MLc JGMQ== 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 m27si495770eja.699.2020.06.29.15.05.17; Mon, 29 Jun 2020 15:05:40 -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 S2391805AbgF2WEG (ORCPT + 99 others); Mon, 29 Jun 2020 18:04:06 -0400 Received: from mga17.intel.com ([192.55.52.151]:13064 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391789AbgF2WEB (ORCPT ); Mon, 29 Jun 2020 18:04:01 -0400 IronPort-SDR: DHbY/j1+e5YRByWtjoNiEmCgRPpCVnSwSkLrr85eCRZ1qWZRt3T6hfjkORSFy7VK8WoOAtBt+u 0gpQxvZdnaNA== X-IronPort-AV: E=McAfee;i="6000,8403,9666"; a="126217642" X-IronPort-AV: E=Sophos;i="5.75,295,1589266800"; d="scan'208";a="126217642" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Jun 2020 15:04:00 -0700 IronPort-SDR: SreirR+rW8l5lvYprSMfMupp38yiGawA6y2IndIaYKmlSV9rQeGpcfGD8AVlg9Nf7e28dnSeBc NDZmcB9roRzw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,295,1589266800"; d="scan'208";a="454351736" Received: from sjchrist-coffee.jf.intel.com (HELO linux.intel.com) ([10.54.74.152]) by orsmga005.jf.intel.com with ESMTP; 29 Jun 2020 15:04:00 -0700 Date: Mon, 29 Jun 2020 15:04:00 -0700 From: Sean Christopherson 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 , Andy Lutomirski , 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, dave.hansen@intel.com, haitao.huang@intel.com, josh@joshtriplett.org, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com Subject: Re: [PATCH v33 12/21] x86/sgx: Allow a limited use of ATTRIBUTE.PROVISIONKEY for attestation Message-ID: <20200629220400.GI12312@linux.intel.com> References: <20200617220844.57423-1-jarkko.sakkinen@linux.intel.com> <20200617220844.57423-13-jarkko.sakkinen@linux.intel.com> <20200629160242.GB32176@zn.tnic> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200629160242.GB32176@zn.tnic> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 06:02:42PM +0200, Borislav Petkov wrote: > On Thu, Jun 18, 2020 at 01:08:34AM +0300, Jarkko Sakkinen wrote: > > Provisioning Certification Enclave (PCE), the root of trust for other > > enclaves, generates a signing key from a fused key called Provisioning > > Certification Key. PCE can then use this key to certify an attestation key > > of a QE, e.g. we get the chain of trust down to the hardware if the Intel > > What's a QE? > > I don't see this acronym resolved anywhere in the whole patchset. Quoting Enclave. > > signed PCE is used. > > > > To use the needed keys, ATTRIBUTE.PROVISIONKEY is required but should be > > only allowed for those who actually need it so that only the trusted > > parties can certify QE's. > > > > Obviously the attestation service should know the public key of the used > > PCE and that way detect illegit attestation, but whitelisting the legit > > users still adds an additional layer of defence. > > > > Add new device file called /dev/sgx/provision. The sole purpose of this > > file is to provide file descriptors that act as privilege tokens to allow > > to build enclaves with ATTRIBUTE.PROVISIONKEY set. A new ioctl called > > SGX_IOC_ENCLAVE_SET_ATTRIBUTE is used to assign this token to an enclave. > > So I'm sure I'm missing something here: what controls which > enclave can open /dev/sgx/provision and thus pass the FD to > SGX_IOC_ENCLAVE_SET_ATTRIBUTE? /dev/sgx/provision is root-only by default, the expectation is that the admin will configure the system to grant only specific enclaves access to the PROVISION_KEY. > And in general, how does that whole flow look like: what calls > SGX_IOC_ENCLAVE_SET_ATTRIBUTE when? The basic gist is that the host process of an enclave that needs/wants access to the PROVISION_KEY will invoke SGX_IOC_ENCLAVE_SET_ATTRIBUTE when building the enclave. Any enclave can request access to PROVISION_KEY, but practically speaking only the PCE and QE (or their non-Intel equivalents) actually need access to the key. KVM (future series) will also respect /dev/sgx/provision, i.e. require a similar ioctl() to expose the PROVISION_KEY to a guest. E.g. for my own personal testing, I never do anything attestation related, so none of the enclaves I run request PROVISION_KEY, but I do expose it to VMs to test the KVM paths. In this series, access is fairly binary, i.e. there's no additional kernel infrastructure to help userspace make per-enclave decisions. There have been more than a few proposals on how to extend the kernel to help provide better granularity, e.g. LSM hooks, but it was generally agreed to punt that stuff to post-upstreaming to keep things "simple" once we went far enough down various paths to ensure we weren't painting ourselves into a corner. If you want super gory details, Intel's whitepaper on attestation in cloud environments is a good starting point[*], but I don't recommended doing much more than skimming unless you really like attestation stuff or are masochistic, which IMO amount to the same thing :-) [*] https://download.01.org/intel-sgx/dcap-1.0/docs/SGX_ECDSA_QuoteGenReference_DCAP_API_Linux_1.0.pdf