Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2985480imu; Mon, 19 Nov 2018 09:00:41 -0800 (PST) X-Google-Smtp-Source: AJdET5cLkZN/+YZYk1bjlDYAVvC0XoeJdililcfcFC1/6vFs9Y3A7gbhBODUmu8x+96m5BaMWQTb X-Received: by 2002:a63:9dca:: with SMTP id i193-v6mr19324390pgd.98.1542646841563; Mon, 19 Nov 2018 09:00:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542646841; cv=none; d=google.com; s=arc-20160816; b=zDKsJ6bbZsclM9RRRkY4eJ8cj8Nx8LH9EE2ouW04qHrfjPTIu47FQBzDAgwZY1kDwX 3mj7fu6PdGJIglDFdqaQmqaTLS6dcalaRw1wQvwPXbMPeWGQ+KvvTGnc56Mwz8EB63nD ANZx4ri/PtUVBp2KxLQ/kUsBp+cZmuLOGTFYyKfCWUQfOdEjQc7MLjmaWbcARzXF02Ix YtnfLK1a4t+UcZh+LhcI+mBZZcvaW39REBzff9ksrZnWPmfBBkyJ+7uwz5evYtNglAdr NR6wIWTqR+o/2dI5HNOubjCz0I0PGTkrG1SlkfRLDr+p0RmYqu9YUprCfQn5cN+0iiSK gsBw== 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=dnO+KI2zslD6ss3tS/w0B8InB8HwqMSPdTgrBSwIvRw=; b=Te+krz25PseY1kHZw0LTDmyxfTZae/dNQib7ZjdoBvvyzB++CJXpHojZh7g/qDEDcM hGI6USS5eJKhEdH/ShG5CxblKvda9pSrheqkHqEgUovKn9w+MOyi/k33oDf8ASG7xfNw saOte6kCsxhcsCXIMnsYcgS+kfNmQAgnRCm7ycu2AQqEIAbP7RDEPlsljeXUSIlIiqqh bSk4I2jvVsoVQNWMNUNLE1GrBBACUNA0WkpOndsTmbxQK3N8JMtvxnhTf9wBte3wM2S8 AsmgH8eOp2Ny1V3TUwcfTHG/TJIiWqhbJo2IY0rHbewEzizDYV9ILBU3xAkSyWE0fmeQ Qpww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="nRo9bT/Y"; 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 q61-v6si40523759plb.418.2018.11.19.09.00.24; Mon, 19 Nov 2018 09:00:41 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b="nRo9bT/Y"; 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 S2405147AbeKTDXz (ORCPT + 99 others); Mon, 19 Nov 2018 22:23:55 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34915 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405131AbeKTDXz (ORCPT ); Mon, 19 Nov 2018 22:23:55 -0500 Received: by mail-wm1-f67.google.com with SMTP id t15-v6so6006537wmt.0 for ; Mon, 19 Nov 2018 08:59:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=dnO+KI2zslD6ss3tS/w0B8InB8HwqMSPdTgrBSwIvRw=; b=nRo9bT/YdQmkQZkECAaVZuEw0/7HpDP3kZDW3tmRomIqFozct9haS6Nm57xuB/9rnF qFNJ/+YZiK7tFEWJXODuaBXldeHItg2qeJbKYbcEMh8DleXsl/nnafWRAWvCKjpeN/s9 hmiEEyF/k7y5yT4WRp3i1MqLR5HbhpciMWHHRT1nub7jlp1zOCHBGWQeApnE+8XhsOrG 76Bg3hzoXTXewjNQgWSW9pgpyC8JpkomOtRMOYnx4HyLSz/xlbKzwzAQJHOXGrJPKrXD ZCNCPiY5bQol0EvRNPCsG8EQ9zF2O0Nk8Hm+j4stN+1xWXnSeCSv+HkBO1hBI089Kli/ /aHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=dnO+KI2zslD6ss3tS/w0B8InB8HwqMSPdTgrBSwIvRw=; b=VHWkyzBE+kkjlvTdZK6bnLUykvCxtDgYVadmmmESLSX+Zm3dWdcF1uKtO2cL0VbBkz FpuLX7O00k01TQYCRb6DdvXsGHG2FIzoNnAEtjbjbNmz+AIHH3g85bRcJRKUr453RnBh bOrOCLn+Qpp/DfYAU627RVGKia6WS6r0ALqT2j4vTup1q3LRWza+Z5IwNh7mAMjziu2n gAyLFVZZ5T1DJiaV9mKjmIZm2UX3uf9TxEFLkx6VCQcbfyvwATBfGpYIXRmRTNeR9ugx BaEE45nGj0RvDEZXt3CtF7nNRGYjYAb576Pm8XLsGytECymyUDH6IBUQ8edTsIDvnpSr lbSA== X-Gm-Message-State: AA+aEWYEKmc/aqTAR7DLKbKbZ4PJGiaUbJ90azpBnjsCW6ZemKrUIi/s /boqGb35eVoM+fH6bnlFW44PhF4iCURAc48JGOSZHA== X-Received: by 2002:a1c:110b:: with SMTP id 11mr5052294wmr.83.1542646776903; Mon, 19 Nov 2018 08:59:36 -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> In-Reply-To: <20181119161917.GF13298@linux.intel.com> From: Andy Lutomirski Date: Mon, 19 Nov 2018 08:59:24 -0800 Message-ID: Subject: Re: [PATCH v17 18/23] platform/x86: Intel SGX driver To: Jarkko Sakkinen Cc: 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 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 Mon, Nov 19, 2018 at 8:19 AM Jarkko Sakkinen wrote: > > On Mon, Nov 19, 2018 at 07:29:25AM -0800, Andy Lutomirski wrote: > > On Thu, Nov 15, 2018 at 5:08 PM Jarkko Sakkinen > > wrote: > > > > > > Intel Software Guard eXtensions (SGX) is a set of CPU instructions that > > > can be used by applications to set aside private regions of code and > > > data. The code outside the enclave is disallowed to access the memory > > > inside the enclave by the CPU access control. > > > > > > SGX driver provides a ioctl API for loading and initializing enclaves. > > > Address range for enclaves is reserved with mmap() and they are > > > destroyed with munmap(). Enclave construction, measurement and > > > initialization is done with the provided the ioctl API. > > > > > > > I brought this up a while back, and I think I should re-ask it now > > that this driver is getting close to ready: > > > > As it stands, there's just one SGX character device, and I imagine > > that it'll be available to unprivileged applications. I'm concerned > > that this isn't quite what we want. I certainly think that everyone, > > or at least almost everyone, ought to be able to run normal enclaves. > > But I think that we should consider restricting who can run specially > > privileged enclaves. In particular, the ability to run enclaves with > > the provisioning bit set is somewhat sensitive, since it effectively > > allows access to a stable fingerprint of the system. Before flexible > > LC, this wasn't such a big deal, since only Intel's provisioning > > enclave could see the key, and Intel's enclave has some degree of > > control of what is done with the key. With flex LC, this protection > > is lost. > > > > But this is maybe more of a big deal than just access to a stable > > fingerprint. The ability to provision a remote attestation protocol > > is a key part of running SGX malware, and SGX malware is surely going > > to exist some day. (Sure, Intel will try to block access to the > > actual attestation service for malware, but I doubt that Intel will be > > able to fully defend it.) > > > > So I propose that there be a few device nodes. Maybe > > /dev/sgx/unprivilegd and /dev/sgx/provisioning? The default mode of > > the latter could be 0600. If you've opened the unprivileged node, you > > can only run enclaves without any special permission bits set. > > What would the use case for unprivileged i.e. this configuration would > mean depending on permissions? Everything except the quoting/provisioning code would use the unprivileged node. > > There would be three types of users: > > 1. Ones that have access to neither of the devices. > 2. Ones that have access to unprivileged. Who are these? Either 0666 (world) or an sgx group. > 3. Ones that have access to provisioning. Root only. 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? --Andy