Skip to contentSkip to conversation

Intel Secure Guard Extensions

PATCH In review Jarkko Sakkinen 12 participants 72 messages Apr 25, 2016 – May 17, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover Intel Secure Guard Extensions

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

Jarkko Sakkinen (5):
x86, sgx: common macros and definitions
intel_sgx: driver for Intel Secure Guard eXtensions
intel_sgx: ptrace() support for the driver
intel_sgx: driver documentation
intel_sgx: TODO file for the staging area

Kai Huang (1):
x86: add SGX definition to cpufeature

 Documentation/x86/intel_sgx.txt               |  86 +++
 arch/x86/include/asm/cpufeature.h             |   1 +
 arch/x86/include/asm/sgx.h                    | 253 +++++++
 drivers/staging/Kconfig                       |   2 +
 drivers/staging/Makefile                      |   1 +
 drivers/staging/intel_sgx/Kconfig             |  13 +
 drivers/staging/intel_sgx/Makefile            |  12 +
 drivers/staging/intel_sgx/TODO                |  25 +
 drivers/staging/intel_sgx/isgx.h              | 238 +++++++
 drivers/staging/intel_sgx/isgx_compat_ioctl.c | 179 +++++
 drivers/staging/intel_sgx/isgx_ioctl.c        | 926 ++++++++++++++++++++++++++
 drivers/staging/intel_sgx/isgx_main.c         | 369 ++++++++++
 drivers/staging/intel_sgx/isgx_page_cache.c   | 485 ++++++++++++++
 drivers/staging/intel_sgx/isgx_user.h         | 113 ++++
 drivers/staging/intel_sgx/isgx_util.c         | 334 ++++++++++
 drivers/staging/intel_sgx/isgx_vma.c          | 400 +++++++++++
 16 files changed, 3437 insertions(+)
 create mode 100644 Documentation/x86/intel_sgx.txt
 create mode 100644 arch/x86/include/asm/sgx.h
 create mode 100644 drivers/staging/intel_sgx/Kconfig
 create mode 100644 drivers/staging/intel_sgx/Makefile
 create mode 100644 drivers/staging/intel_sgx/TODO
 create mode 100644 drivers/staging/intel_sgx/isgx.h
 create mode 100644 drivers/staging/intel_sgx/isgx_compat_ioctl.c
 create mode 100644 drivers/staging/intel_sgx/isgx_ioctl.c
 create mode 100644 drivers/staging/intel_sgx/isgx_main.c
 create mode 100644 drivers/staging/intel_sgx/isgx_page_cache.c
 create mode 100644 drivers/staging/intel_sgx/isgx_user.h
 create mode 100644 drivers/staging/intel_sgx/isgx_util.c
 create mode 100644 drivers/staging/intel_sgx/isgx_vma.c
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/6 x86: add SGX definition to cpufeature

From: Kai Huang <[email protected]>

---
 arch/x86/include/asm/cpufeature.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/cpufeature.h +1 -0
index 7ad8c94..f6be49f 100644
@@ -208,6 +208,7 @@
 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
 #define X86_FEATURE_FSGSBASE	( 9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
 #define X86_FEATURE_TSC_ADJUST	( 9*32+ 1) /* TSC adjustment MSR 0x3b */
+#define X86_FEATURE_SGX		( 9*32+ 2) /* Software Guard Extensions */
 #define X86_FEATURE_BMI1	( 9*32+ 3) /* 1st group bit manipulation extensions */
 #define X86_FEATURE_HLE		( 9*32+ 4) /* Hardware Lock Elision */
 #define X86_FEATURE_AVX2	( 9*32+ 5) /* AVX2 instructions */
Signature · 1 line
2.7.4
#4 lore raw

PATCH 2/6 x86, sgx: common macros and definitions

In reply to Jarkko Sakkinen

Added arch/x86/include/asm/sgx.h that contains common architectural macros and definitions that are shared with the SGX driver and kernel virtualization code.

---
 arch/x86/include/asm/sgx.h | 253 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 253 insertions(+)
 create mode 100644 arch/x86/include/asm/sgx.h
arch/x86/include/asm/sgx.h new file +253 -0
new file mode 100644
index 0000000..ef9f20f
@@ -0,0 +1,253 @@
+/*
+ * (C) Copyright 2016 Intel Corporation
+ *
+ * Authors:
+ *
+ * Jarkko Sakkinen <[email protected]>
+ * Suresh Siddha <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+#ifndef _ASM_X86_SGX_H
+#define _ASM_X86_SGX_H
+
+#include <asm/asm.h>
+#include <linux/bitops.h>
+#include <linux/types.h>
+
+#define SGX_CPUID		0x12
+
+enum sgx_page_type {
+	SGX_PAGE_TYPE_SECS	= 0x00,
+	SGX_PAGE_TYPE_TCS	= 0x01,
+	SGX_PAGE_TYPE_REG	= 0x02,
+	SGX_PAGE_TYPE_VA	= 0x03,
+};
+
+enum sgx_secs_attributes {
+	SGX_SECS_A_DEBUG		= BIT_ULL(1),
+	SGX_SECS_A_MODE64BIT		= BIT_ULL(2),
+	SGX_SECS_A_PROVISION_KEY	= BIT_ULL(4),
+	SGX_SECS_A_LICENSE_KEY		= BIT_ULL(5),
+	SGX_SECS_A_RESERVED_MASK	= (BIT_ULL(0) |
+					   BIT_ULL(3) |
+					   GENMASK_ULL(63, 6)),
+};
+
+#define SGX_SECS_RESERVED1_SIZE 28
+#define SGX_SECS_RESERVED2_SIZE 32
+#define SGX_SECS_RESERVED3_SIZE 96
+#define SGX_SECS_RESERVED4_SIZE 3836
+
+struct sgx_secs {
+	u64	size;
+	u64	base;
+	u32	ssaframesize;
+	uint8_t reserved1[SGX_SECS_RESERVED1_SIZE];
+	u64	flags;
+	u64	xfrm;
+	u32	mrenclave[8];
+	uint8_t	reserved2[SGX_SECS_RESERVED2_SIZE];
+	u32	mrsigner[8];
+	uint8_t	reserved3[SGX_SECS_RESERVED3_SIZE];
+	u16	isvvprodid;
+	u16	isvsvn;
+	uint8_t	reserved[SGX_SECS_RESERVED4_SIZE];
+};
+
+struct sgx_tcs {
+	u64 state;
+	u64 flags;
+	u64 ossa;
+	u32 cssa;
+	u32 nssa;
+	u64 oentry;
+	u64 aep;
+	u64 ofsbase;
+	u64 ogsbase;
+	u32 fslimit;
+	u32 gslimit;
+	u64 reserved[503];
+};
+
+enum sgx_secinfo_masks {
+	ISGX_SECINFO_PERMISSION_MASK	= GENMASK_ULL(2, 0),
+	ISGX_SECINFO_PAGE_TYPE_MASK	= GENMASK_ULL(15, 8),
+	ISGX_SECINFO_RESERVED_MASK	= (GENMASK_ULL(7, 3) |
+					   GENMASK_ULL(63, 16)),
+};
+
+struct sgx_pcmd {
+	struct isgx_secinfo secinfo;
+	u64 enclave_id;
+	u8 reserved[40];
+	u8 mac[16];
+};
+
+struct sgx_page_info {
+	u64 linaddr;
+	u64 srcpge;
+	union {
+		u64 secinfo;
+		u64 pcmd;
+	};
+	u64 secs;
+} __aligned(32);
+
+#define SIGSTRUCT_SIZE 1808
+#define EINITTOKEN_SIZE 304
+
+enum {
+	ECREATE	= 0x0,
+	EADD	= 0x1,
+	EINIT	= 0x2,
+	EREMOVE	= 0x3,
+	EDGBRD	= 0x4,
+	EDGBWR	= 0x5,
+	EEXTEND	= 0x6,
+	ELDU	= 0x8,
+	EBLOCK	= 0x9,
+	EPA	= 0xA,
+	EWB	= 0xB,
+	ETRACK	= 0xC,
+};
+
+#define __encls_ret(rax, rbx, rcx, rdx)			\
+	({						\
+	int ret;					\
+	asm volatile(					\
+	"1: .byte 0x0f, 0x01, 0xcf;\n\t"		\
+	"2:\n"						\
+	".section .fixup,\"ax\"\n"			\
+	"3: jmp 2b\n"					\
+	".previous\n"					\
+	_ASM_EXTABLE(1b, 3b)				\
+	: "=a"(ret)					\
+	: "a"(rax), "b"(rbx), "c"(rcx), "d"(rdx)	\
+	: "memory");					\
+	ret;						\
+	})
+
+#ifdef CONFIG_X86_64
+#define __encls(rax, rbx, rcx, rdx...)			\
+	({						\
+	int ret;					\
+	asm volatile(					\
+	"1: .byte 0x0f, 0x01, 0xcf;\n\t"		\
+	"   xor %%eax,%%eax;\n"				\
+	"2:\n"						\
+	".section .fixup,\"ax\"\n"			\
+	"3: movq $-1,%%rax\n"				\
+	"   jmp 2b\n"					\
+	".previous\n"					\
+	_ASM_EXTABLE(1b, 3b)				\
+	: "=a"(ret), "=b"(rbx), "=c"(rcx)		\
+	: "a"(rax), "b"(rbx), "c"(rcx), rdx		\
+	: "memory");					\
+	ret;						\
+	})
+#else
+#define __encls(rax, rbx, rcx, rdx...)			\
+	({						\
+	int ret;					\
+	asm volatile(					\
+	"1: .byte 0x0f, 0x01, 0xcf;\n\t"		\
+	"   xor %%eax,%%eax;\n"				\
+	"2:\n"						\
+	".section .fixup,\"ax\"\n"			\
+	"3: mov $-1,%%eax\n"				\
+	"   jmp 2b\n"					\
+	".previous\n"					\
+	_ASM_EXTABLE(1b, 3b)				\
+	: "=a"(ret), "=b"(rbx), "=c"(rcx)		\
+	: "a"(rax), "b"(rbx), "c"(rcx), rdx		\
+	: "memory");					\
+	ret;						\
+	})
+#endif
+
+static inline unsigned long __ecreate(struct sgx_page_info *pginfo, void *secs)
+{
+	return __encls(ECREATE, pginfo, secs, "d"(0));
+}
+
+static inline int __eextend(void *secs, void *epc)
+{
+	return __encls(EEXTEND, secs, epc, "d"(0));
+}
+
+static inline int __eadd(struct sgx_page_info *pginfo, void *epc)
+{
+	return __encls(EADD, pginfo, epc, "d"(0));
+}
+
+static inline int __einit(void *sigstruct, struct isgx_einittoken *einittoken,
+			  void *secs)
+{
+	return __encls_ret(EINIT, sigstruct, secs, einittoken);
+}
+
+static inline int __eremove(void *epc)
+{
+	unsigned long rbx = 0;
+	unsigned long rdx = 0;
+
+	return __encls_ret(EREMOVE, rbx, epc, rdx);
+}
+
+static inline int __edbgwr(void *epc, unsigned long *data)
+{
+	return __encls(EDGBWR, *data, epc, "d"(0));
+}
+
+static inline int __edbgrd(void *epc, unsigned long *data)
+{
+	unsigned long rbx = 0;
+	int ret;
+
+	ret = __encls(EDGBRD, rbx, epc, "d"(0));
+	if (!ret)
+		*(unsigned long *) data = rbx;
+
+	return ret;
+}
+
+static inline int __etrack(void *epc)
+{
+	unsigned long rbx = 0;
+	unsigned long rdx = 0;
+
+	return __encls_ret(ETRACK, rbx, epc, rdx);
+}
+
+static inline int __eldu(unsigned long rbx, unsigned long rcx,
+			 unsigned long rdx)
+{
+	return __encls_ret(ELDU, rbx, rcx, rdx);
+}
+
+static inline int __eblock(unsigned long rcx)
+{
+	unsigned long rbx = 0;
+	unsigned long rdx = 0;
+
+	return __encls_ret(EBLOCK, rbx, rcx, rdx);
+}
+
+static inline int __epa(void *epc)
+{
+	unsigned long rbx = SGX_PAGE_TYPE_VA;
+
+	return __encls(EPA, rbx, epc, "d"(0));
+}
+
+static inline int __ewb(struct sgx_page_info *pginfo, void *epc, void *va)
+{
+	return __encls_ret(EWB, pginfo, epc, va);
+}
+
+#endif /* _ASM_X86_SGX_H */
Signature · 1 line
2.7.4
#15 lore raw

PATCH 4/6 intel_sgx: ptrace() support for the driver

In reply to Jarkko Sakkinen

This commit implements the 'access' callback for the enclave VMA thus enabling reading and writing the memory of debug enclaves. The page that is accessed is first faulted and marked as reserved so that the EPC evictor will know not to swap the page while it is being manipulated.

---
 drivers/staging/intel_sgx/isgx_vma.c | 118 +++++++++++++++++++++++++++++++++++
 1 file changed, 118 insertions(+)
drivers/staging/intel_sgx/isgx_vma.c +118 -0
index f6cfb02..2788ab9 100644
@@ -275,8 +275,126 @@ static int isgx_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 		return VM_FAULT_SIGBUS;
 }
 
+static inline int isgx_vma_access_word(struct isgx_enclave *enclave,
+				       unsigned long addr,
+				       void *buf,
+				       int len,
+				       int write,
+				       struct isgx_enclave_page *enclave_page,
+				       int i)
+{
+	char data[sizeof(unsigned long)];
+	int align, cnt, offset;
+	void *vaddr;
+	int ret;
+
+	offset = ((addr + i) & (PAGE_SIZE - 1)) & ~(sizeof(unsigned long) - 1);
+	align = (addr + i) & (sizeof(unsigned long) - 1);
+	cnt = sizeof(unsigned long) - align;
+	cnt = min(cnt, len - i);
+
+	if (write) {
+		if (enclave_page->flags & ISGX_ENCLAVE_PAGE_TCS &&
+		    (offset < 8 || (offset + (len - i)) > 16))
+			return -ECANCELED;
+
+		if (align || (cnt != sizeof(unsigned long))) {
+			vaddr = isgx_get_epc_page(enclave_page->epc_page);
+			ret = __edbgrd((void *)((unsigned long)vaddr + offset),
+				       (unsigned long *)data);
+			isgx_put_epc_page(vaddr);
+			if (ret) {
+				isgx_dbg(enclave, "EDBGRD returned %d\n", ret);
+				return -EFAULT;
+			}
+		}
+
+		memcpy(data + align, buf + i, cnt);
+		vaddr = isgx_get_epc_page(enclave_page->epc_page);
+		ret = __edbgwr((void *)((unsigned long)vaddr + offset),
+			       (unsigned long *)data);
+		isgx_put_epc_page(vaddr);
+		if (ret) {
+			isgx_dbg(enclave, "EDBGWR returned %d\n", ret);
+			return -EFAULT;
+		}
+	} else {
+		if (enclave_page->flags & ISGX_ENCLAVE_PAGE_TCS &&
+		    (offset + (len - i)) > 72)
+			return -ECANCELED;
+
+		vaddr = isgx_get_epc_page(enclave_page->epc_page);
+		ret = __edbgrd((void *)((unsigned long)vaddr + offset),
+			       (unsigned long *)data);
+		isgx_put_epc_page(vaddr);
+		if (ret) {
+			isgx_dbg(enclave, "EDBGRD returned %d\n", ret);
+			return -EFAULT;
+		}
+
+		memcpy(buf + i, data + align, cnt);
+	}
+
+	return cnt;
+}
+
+static int isgx_vma_access(struct vm_area_struct *vma, unsigned long addr,
+			   void *buf, int len, int write)
+{
+	struct isgx_enclave *enclave = vma->vm_private_data;
+	struct isgx_enclave_page *entry = NULL;
+	const char *op_str = write ? "EDBGWR" : "EDBGRD";
+	int ret = 0;
+	int i;
+
+	/* If process was forked, VMA is still there but vm_private_data is set
+	 * to NULL.
+	 */
+	if (!enclave)
+		return -EFAULT;
+
+	if (!(enclave->flags & ISGX_ENCLAVE_DEBUG) ||
+	    !(enclave->flags & ISGX_ENCLAVE_INITIALIZED) ||
+	    (enclave->flags & ISGX_ENCLAVE_SUSPEND))
+		return -EFAULT;
+
+	isgx_dbg(enclave, "%s addr=0x%lx, len=%d\n", op_str, addr, len);
+
+	for (i = 0; i < len; i += ret) {
+		if (!entry || !((addr + i) & (PAGE_SIZE - 1))) {
+			if (entry)
+				entry->flags &= ~ISGX_ENCLAVE_PAGE_RESERVED;
+
+			do {
+				entry = isgx_vma_do_fault(
+					vma, (addr + i) & PAGE_MASK, true);
+			} while (entry == ERR_PTR(-EBUSY));
+
+			if (IS_ERR(entry)) {
+				ret = PTR_ERR(entry);
+				entry = NULL;
+				break;
+			}
+		}
+
+		/* No locks are needed because used fields are immutable after
+		 * intialization.
+		 */
+		ret = isgx_vma_access_word(enclave, addr, buf, len, write,
+					   entry, i);
+		if (ret < 0)
+			break;
+	}
+
+	if (entry)
+		entry->flags &= ~ISGX_ENCLAVE_PAGE_RESERVED;
+
+	return (ret < 0 && ret != -ECANCELED) ? ret : i;
+}
+
 struct vm_operations_struct isgx_vm_ops = {
 	.close = isgx_vma_close,
 	.open = isgx_vma_open,
 	.fault = isgx_vma_fault,
+	.access = isgx_vma_access,
 };
Signature · 1 line
2.7.4
#16 lore raw

PATCH 5/6 intel_sgx: driver documentation

In reply to Jarkko Sakkinen
---
 Documentation/x86/intel_sgx.txt | 86 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
 create mode 100644 Documentation/x86/intel_sgx.txt
Documentation/x86/intel_sgx.txt new file +86 -0
new file mode 100644
index 0000000..f26b50b
@@ -0,0 +1,86 @@
+1. Intel(R) SGX overview
+========================
+
+Intel(R) 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.
+
+There is a new hardware unit in the processor called Memory Encryption Engine
+(MEE) starting from the Skylake microachitecture. BIOS can define one or many
+MEE regions that can hold enclave data by configuring them with PRMRR registers.
+
+The MEE automatically encrypts the data leaving the processor package to the MEE
+regions. The data is encrypted using a random key whose life-time is exactly one
+power cycle.
+
+You can tell if your CPU supports SGX by looking into /proc/cpuinfo:
+
+	cat /proc/cpuinfo  | grep ' sgx '
+
+2. Enclaves overview
+====================
+
+SGX defines new data types to maintain information about the enclaves and their
+security properties.
+
+The following data structures exist in MEE regions:
+
+* Enclave Page Cache (EPC): protected code and data
+* Enclave Page Cache Map (EPCM): meta-data for each EPC page
+
+The Enclave Page Cache can hold following types EPC pages:
+
+* SGX Enclave Control Structure (SECS): contains meta-data defining the global
+  properties of an enclave such as range of addresses it can access.
+* Regular EPC pages containing code and data for the enclave.
+* Thread Control Structure (TCS): defines an entry point for a hardware thread
+  to enter into the enclave. The enclave can only be entered through these entry
+  points.
+* Version Array (VA): an EPC page receives a unique version number when it is
+  evicted that is stored into a VA page. A VA page can hold up to 512 version
+  numbers.
+
+There are leaf instructions called EADD and EEXTEND that can be used to add and
+measure an enclave to a virtual address space.
+
+When initializing an enclave a SIGSTRUCT must provided for the EINIT leaf
+instruction that contains signed measurement of the enclave binary. For so
+called architectural enclaves (AEs) this structure is signed with Intel Root of
+Trust.
+
+For normal application specific enclaves a cryptographic token called EINITTOKEN
+must be provided that is signed with Intel RoT. There is an AE called License
+Enclave that provides this token given by a SIGSTRUCT instance. It checks
+whether the public key contained inside SIGSTRUCT is whitelisted and generates
+EINITTOKEN if it is.
+
+There is a special type of enclave called debug enclave that is convenient when
+the enclave code is being developed. These enclaves can be read and write by
+using EDBGWR and EDBGRD leaf instructions. The kernel driver provides ptrace()
+interface for enclaves by using these instructions.
+
+Another benefit with debug enclaves is that LE will ignore the white list
+and always generates EINITTOKEN.
+
+3. IOCTL API
+============
+
+The ioctl API is defined in arch/x86/include/uapi/asm/sgx.h.
+
+SGX_IOCTL_ENCLAVE_CREATE
+
+Creates a VMA and a SECS page for the enclave.
+
+SGX_IOCTL_ENCLAVE_ADD_PAGE
+
+Adds and measures a new EPC page for the enclave. Must be in the range defined
+by SGX_IOCTL_ENCLAVE_CREATE. This will copy the page data and it to a workqueue
+that will eventually execute EADD and EEXTEND leaf instruction that add and
+measure the page.
+
+SGX_IOCTL_ENCLAVE_INIT
+
+Initializes an enclave given by SIGSTRUCT and EINITTOKEN. Executes EINIT leaf
+instruction that will check that the measurement matches the one SIGSTRUCT and
+EINITTOKEN. EINITTOKEN is a data blob given by a special enclave called Launch
+Enclave and it is signed with a CPU's Launch Key.
Signature · 1 line
2.7.4
#5 lore raw

PATCH 3/6 intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jarkko Sakkinen

Intel(R) 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.

Intel SGX driver provides a ioctl interface for loading and initializing enclaves and a pager in order to support oversubscription.

---
 arch/x86/include/asm/sgx.h                    |   4 +-
 drivers/staging/Kconfig                       |   2 +
 drivers/staging/Makefile                      |   1 +
 drivers/staging/intel_sgx/Kconfig             |  13 +
 drivers/staging/intel_sgx/Makefile            |  12 +
 drivers/staging/intel_sgx/isgx.h              | 238 +++++++
 drivers/staging/intel_sgx/isgx_compat_ioctl.c | 179 +++++
 drivers/staging/intel_sgx/isgx_ioctl.c        | 926 ++++++++++++++++++++++++++
 drivers/staging/intel_sgx/isgx_main.c         | 369 ++++++++++
 drivers/staging/intel_sgx/isgx_page_cache.c   | 485 ++++++++++++++
 drivers/staging/intel_sgx/isgx_user.h         | 113 ++++
 drivers/staging/intel_sgx/isgx_util.c         | 334 ++++++++++
 drivers/staging/intel_sgx/isgx_vma.c          | 282 ++++++++
 13 files changed, 2956 insertions(+), 2 deletions(-)
 create mode 100644 drivers/staging/intel_sgx/Kconfig
 create mode 100644 drivers/staging/intel_sgx/Makefile
 create mode 100644 drivers/staging/intel_sgx/isgx.h
 create mode 100644 drivers/staging/intel_sgx/isgx_compat_ioctl.c
 create mode 100644 drivers/staging/intel_sgx/isgx_ioctl.c
 create mode 100644 drivers/staging/intel_sgx/isgx_main.c
 create mode 100644 drivers/staging/intel_sgx/isgx_page_cache.c
 create mode 100644 drivers/staging/intel_sgx/isgx_user.h
 create mode 100644 drivers/staging/intel_sgx/isgx_util.c
 create mode 100644 drivers/staging/intel_sgx/isgx_vma.c
arch/x86/include/asm/sgx.h +2 -2
index ef9f20f..5e2692d 100644
@@ -82,7 +82,7 @@ enum sgx_secinfo_masks {
 };
 
 struct sgx_pcmd {
-	struct isgx_secinfo secinfo;
+	struct sgx_secinfo secinfo;
 	u64 enclave_id;
 	u8 reserved[40];
 	u8 mac[16];
@@ -185,7 +185,7 @@ static inline int __eadd(struct sgx_page_info *pginfo, void *epc)
 	return __encls(EADD, pginfo, epc, "d"(0));
 }
 
-static inline int __einit(void *sigstruct, struct isgx_einittoken *einittoken,
+static inline int __einit(void *sigstruct, struct sgx_einittoken *einittoken,
 			  void *secs)
 {
 	return __encls_ret(EINIT, sigstruct, secs, einittoken);
drivers/staging/Kconfig +2 -0
index 5d3b86a..dc64d4b 100644
@@ -110,4 +110,6 @@ source "drivers/staging/wilc1000/Kconfig"
 
 source "drivers/staging/most/Kconfig"
 
+source "drivers/staging/intel_sgx/Kconfig"
+
 endif # STAGING
drivers/staging/Makefile +1 -0
index 30918ed..992377b 100644
@@ -47,3 +47,4 @@ obj-$(CONFIG_FB_TFT)		+= fbtft/
 obj-$(CONFIG_FSL_MC_BUS)	+= fsl-mc/
 obj-$(CONFIG_WILC1000)		+= wilc1000/
 obj-$(CONFIG_MOST)		+= most/
+obj-$(CONFIG_INTEL_SGX)		+= intel_sgx/
drivers/staging/intel_sgx/Kconfig new file +13 -0
new file mode 100644
index 0000000..74e3880
@@ -0,0 +1,13 @@
+config INTEL_SGX
+	tristate "Intel(R) SGX Driver"
+	depends on X86
+	---help---
+	Intel(R) 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.
+
+	The firmware uses PRMRR registers to reserve an area of physical memory
+	called Enclave Page Cache (EPC). There is a hardware unit in the
+	processor called Memory Encryption Engine. The MEE encrypts and decrypts
+	the EPC pages as they enter and leave the processor package.
drivers/staging/intel_sgx/Makefile new file +12 -0
new file mode 100644
index 0000000..cc38853
@@ -0,0 +1,12 @@
+obj-$(CONFIG_INTEL_SGX) += intel_sgx.o
+
+intel_sgx-$(CONFIG_INTEL_SGX) += \
+	isgx_ioctl.o \
+	isgx_main.o \
+	isgx_page_cache.o \
+	isgx_util.o \
+	isgx_vma.o
+
+ifdef CONFIG_COMPAT
+intel_sgx-$(CONFIG_INTEL_SGX) += isgx_compat_ioctl.o
+endif
drivers/staging/intel_sgx/isgx.h new file +238 -0

238 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_compat_ioctl.c new file +179 -0

179 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_ioctl.c new file +926 -0

926 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_main.c new file +369 -0

369 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_page_cache.c new file +485 -0

485 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_user.h new file +113 -0

113 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_util.c new file +334 -0

334 lines not on this page · raw message

drivers/staging/intel_sgx/isgx_vma.c new file +282 -0

282 lines not on this page · raw message

Signature · 1 line
2.7.4
#22 lore raw

PATCH 6/6 intel_sgx: TODO file for the staging area

In reply to Jarkko Sakkinen
---
 drivers/staging/intel_sgx/TODO | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 drivers/staging/intel_sgx/TODO
drivers/staging/intel_sgx/TODO new file +25 -0
new file mode 100644
index 0000000..05f68c2
@@ -0,0 +1,25 @@
+Documentation
+=============
+
+* Improve Documents/x86/intel-sgx.txt based on the feedback and
+  questions that pop up.
+
+Internals
+=========
+
+* Move structures needed by the allocator to arch/x86/include/asm/sgx.h
+* Move EPC page allocation and eviction code to arch/x86/mm as they
+  will shared with virtualization code.
+* Move enclave management functions to arch/x86/mm as they will be
+  shared with virtualization code.
+* Use reserve_memtype() in order to add EPC to the PAT memtype list
+  with WB caching.
+* Implement proper recovery code for the pager for cases when
+  ETRACK/EBLOCK/EWB fails instead of BUG_ON(). Probably the sanest
+  way to recover is to clear TCS PTEs, kick threads out of enclave
+  and remove EPC pages.
+* Implement ACPI hot-lug for SGX.
+
+===
+
+* Move isgx_user.h to arch/x86/include/uapi/asm/sgx.h
Signature · 1 line
2.7.4
maintainer
#30 lore raw
In reply to Jarkko Sakkinen
Quoted 17 lines · Jarkko Sakkinen

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

Jarkko Sakkinen (5):
x86, sgx: common macros and definitions
intel_sgx: driver for Intel Secure Guard eXtensions
intel_sgx: ptrace() support for the driver
intel_sgx: driver documentation
intel_sgx: TODO file for the staging area

Quoted 6 lines

Kai Huang (1):
x86: add SGX definition to cpufeature

 Documentation/x86/intel_sgx.txt               |  86 +++
 arch/x86/include/asm/cpufeature.h             |   1 +
 arch/x86/include/asm/sgx.h                    | 253 +++++++

Why are you asking for this to go into staging?

What is keeping it out of the "real" part of the kernel tree?

And staging code is self-contained, putting files in arch/* isn't ok for it, which kind of implies that you should get this merged correctly.

I need a lot more information here before I can take this code...

thanks,

greg k-h

maintainer
#23 lore raw

Re: [PATCH 6/6] intel_sgx: TODO file for the staging area

In reply to Jarkko Sakkinen
Quoted 23 lines · Jarkko Sakkinen
---
 drivers/staging/intel_sgx/TODO | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 drivers/staging/intel_sgx/TODO
drivers/staging/intel_sgx/TODO new file +11 -0
new file mode 100644
index 0000000..05f68c2
@@ -0,0 +1,25 @@
+Documentation
+=============
+
+* Improve Documents/x86/intel-sgx.txt based on the feedback and
+  questions that pop up.
+
+Internals
+=========
+
+* Move structures needed by the allocator to arch/x86/include/asm/sgx.h
+* Move EPC page allocation and eviction code to arch/x86/mm as they

drivers/staging/intel_sgx/TODO line 21

Quoted 10 lines
drivers/staging/intel_sgx/TODO new file +10 -0
+  will shared with virtualization code.
+* Move enclave management functions to arch/x86/mm as they will be
+  shared with virtualization code.
+* Use reserve_memtype() in order to add EPC to the PAT memtype list
+  with WB caching.
+* Implement proper recovery code for the pager for cases when
+  ETRACK/EBLOCK/EWB fails instead of BUG_ON(). Probably the sanest
+  way to recover is to clear TCS PTEs, kick threads out of enclave
+  and remove EPC pages.
+* Implement ACPI hot-lug for SGX.

What is keeping you from doing all of this work this week, making this todo list empty?

thanks,

greg k-h

maintainer
#6 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen

Intel(R) 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.

Intel SGX driver provides a ioctl interface for loading and initializing enclaves and a pager in order to support oversubscription.

Quoted 8 lines
---
 arch/x86/include/asm/sgx.h                    |   4 +-
 drivers/staging/Kconfig                       |   2 +
 drivers/staging/Makefile                      |   1 +
 drivers/staging/intel_sgx/Kconfig             |  13 +
 drivers/staging/intel_sgx/Makefile            |  12 +
 drivers/staging/intel_sgx/isgx.h              | 238 +++++++
 drivers/staging/intel_sgx/isgx_compat_ioctl.c | 179 +++++

No "new" kernel code should ever need compat_ioctl support, please just create your structures to not require this at all, it isn't that difficult.

thanks,

greg k-h

#24 lore raw

Re: [PATCH 6/6] intel_sgx: TODO file for the staging area

In reply to Greg KH
Quoted 29 lines · Greg KH
Quoted 28 lines · Jarkko Sakkinen
---
 drivers/staging/intel_sgx/TODO | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 drivers/staging/intel_sgx/TODO
drivers/staging/intel_sgx/TODO new file +16 -0
new file mode 100644
index 0000000..05f68c2
@@ -0,0 +1,25 @@
+Documentation
+=============
+
+* Improve Documents/x86/intel-sgx.txt based on the feedback and
+  questions that pop up.
+
+Internals
+=========
+
+* Move structures needed by the allocator to arch/x86/include/asm/sgx.h
+* Move EPC page allocation and eviction code to arch/x86/mm as they
+  will shared with virtualization code.
+* Move enclave management functions to arch/x86/mm as they will be
+  shared with virtualization code.
+* Use reserve_memtype() in order to add EPC to the PAT memtype list
+  with WB caching.
Quoted 8 lines

drivers/staging/intel_sgx/TODO line 21

Quoted 5 lines
drivers/staging/intel_sgx/TODO new file +5 -0
+* Implement proper recovery code for the pager for cases when
+  ETRACK/EBLOCK/EWB fails instead of BUG_ON(). Probably the sanest
+  way to recover is to clear TCS PTEs, kick threads out of enclave
+  and remove EPC pages.
+* Implement ACPI hot-lug for SGX.

What is keeping you from doing all of this work this week, making this todo list empty?

I could. I took the internal driver code and just enumerated the tasks that I saw that need to be done before it's ready from my point of view. I just wanted intial feedback before starting to work through these so that I know my aim is right.

Quoted 3 lines

thanks,

greg k-h

/Jarkko

#31 lore raw
In reply to Greg KH
Quoted 21 lines · Greg KH
Quoted 20 lines · Jarkko Sakkinen

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

Jarkko Sakkinen (5):
x86, sgx: common macros and definitions
intel_sgx: driver for Intel Secure Guard eXtensions
intel_sgx: ptrace() support for the driver
intel_sgx: driver documentation
intel_sgx: TODO file for the staging area

Kai Huang (1):
x86: add SGX definition to cpufeature

Quoted 7 lines
Quoted 3 lines
 Documentation/x86/intel_sgx.txt               |  86 +++
 arch/x86/include/asm/cpufeature.h             |   1 +
 arch/x86/include/asm/sgx.h                    | 253 +++++++

Why are you asking for this to go into staging?

What is keeping it out of the "real" part of the kernel tree?

Now that I think of it nothing as long as the API is fixed the way you suggested and my TODO list is cleared.

I think I prepare a new version of the patches and point it directly to arch/x86.

Quoted 8 lines

And staging code is self-contained, putting files in arch/* isn't ok for it, which kind of implies that you should get this merged correctly.

I need a lot more information here before I can take this code...

thanks,

greg k-h

/Jarkko

#7 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Greg KH
Quoted 19 lines · Greg KH
Quoted 9 lines · Jarkko Sakkinen

Intel(R) 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.

Intel SGX driver provides a ioctl interface for loading and initializing enclaves and a pager in order to support oversubscription.

Quoted 8 lines
---
 arch/x86/include/asm/sgx.h                    |   4 +-
 drivers/staging/Kconfig                       |   2 +
 drivers/staging/Makefile                      |   1 +
 drivers/staging/intel_sgx/Kconfig             |  13 +
 drivers/staging/intel_sgx/Makefile            |  12 +
 drivers/staging/intel_sgx/isgx.h              | 238 +++++++
 drivers/staging/intel_sgx/isgx_compat_ioctl.c | 179 +++++
Quoted 3 lines

No "new" kernel code should ever need compat_ioctl support, please just create your structures to not require this at all, it isn't that difficult.

I'll rework this. Thanks for the feedback.

Quoted 3 lines

thanks,

greg k-h

/Jarkko

#25 lore raw

Re: [PATCH 6/6] intel_sgx: TODO file for the staging area

In reply to Jarkko Sakkinen
Quoted 1 line

+* Implement ACPI hot-lug for SGX.

hot-plug

Also with an upstream hat on I would add being able to check the keys on the enclave against a kernel keychain because not everyone will want to solely trust whatever keys the hardware thinks it wants to trust.

Alan

#32 lore raw
In reply to Jarkko Sakkinen
Quoted 28 lines · Jarkko Sakkinen
Quoted 27 lines · Greg KH
Quoted 17 lines · Jarkko Sakkinen

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

Jarkko Sakkinen (5):
x86, sgx: common macros and definitions
intel_sgx: driver for Intel Secure Guard eXtensions
intel_sgx: ptrace() support for the driver
intel_sgx: driver documentation
intel_sgx: TODO file for the staging area

Quoted 6 lines

Kai Huang (1):
x86: add SGX definition to cpufeature

 Documentation/x86/intel_sgx.txt               |  86 +++
 arch/x86/include/asm/cpufeature.h             |   1 +
 arch/x86/include/asm/sgx.h                    | 253 +++++++

Why are you asking for this to go into staging?

Quoted 7 lines
Quoted 1 line

What is keeping it out of the "real" part of the kernel tree?

Now that I think of it nothing as long as the API is fixed the way you suggested and my TODO list is cleared.

I think I prepare a new version of the patches and point it directly to arch/x86.

Thanks. Please cc me as well.

--Andy

Quoted 11 lines
Quoted 9 lines

And staging code is self-contained, putting files in arch/* isn't ok for it, which kind of implies that you should get this merged correctly.

I need a lot more information here before I can take this code...

thanks,

greg k-h

/Jarkko

Signature · 2 lines
Andy Lutomirski
AMA Capital Management, LLC
#3 lore raw

Re: [PATCH 1/6] x86: add SGX definition to cpufeature

Quoted 6 lines · Andy Lutomirski
Quoted 1 line · Jarkko Sakkinen

From: Kai Huang <[email protected]>

Should this come with a nosgx boot option and an IA32_FEATURE_CONTROL check to disable the feature if BIOS doesn't support it?

You can already disable every CPUID feature at boot with clearcpuid=... No point in adding redundant options for everything.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only
#17 lore raw

Re: [PATCH 5/6] intel_sgx: driver documentation

In reply to Jarkko Sakkinen

Documentation/x86/intel_sgx.txt line 86

Quoted 7 lines · Jarkko Sakkinen
Documentation/x86/intel_sgx.txt new file +6 -0
+SGX_IOCTL_ENCLAVE_INIT
+
+Initializes an enclave given by SIGSTRUCT and EINITTOKEN. Executes EINIT leaf
+instruction that will check that the measurement matches the one SIGSTRUCT and
+EINITTOKEN. EINITTOKEN is a data blob given by a special enclave called Launch
+Enclave and it is signed with a CPU's Launch Key.

Having thought about this for ten minutes, I have the following thought:

I think that we should seriously consider not allowing user code to supply EINITTOKEN at all. Here's why:

1. The nominal purpose of this thing is "launch control." I think that the decision of whether to launch an enclave belongs in the kernel to the extent that the kernel has the ability to control this.

2. I think that launch control is actively insecure (assuming that the use case is what I think it is). Since the kernel might have some interest in controlling whether an enclave can launch (I think this is entirely reasonable) and since that policy might reasonably be expressed in the form of a launch enclave, I think that the *kernel* should generate the actual EINITTOKEN object. (I also reported, off-list, what I think is a significant security issue under some usage models that is mitigated if the user isn't allowed to supply their own EINITTOKEN of unknown provenance.)

3. On a CPU with unlocked IA32_SGXLEPUBKEYHASH, I think that the kernel should ship, *in the kernel image*, a binary corresponding to an open-source "launch anything" enclave. The kernel should, when appropriate, use this thing to generate EINITTOKEN objects. User code should *not* have to think about where this "launch anything" enclave comes from or whether it's the same on all kernels. (I think that the best way to do this would be to try to build it deterministically using a well-known key pair. This should be very easy to do.) If someone wants to turn this feature off, let them do so via sysctl.

If someone wants to supply their own launch enclave, then let them either feed it to the kernel or enable some non-default privileged option to allow them to supply EINITTOKEN directly.

Actually implementing this is going to be interesting, because the kernel will have to call out to CPL 3 to do it. It's not *that* hard, though, as the exiting kernel thread API should be more or less adequate.

--Andy

#26 lore raw

Re: [PATCH 6/6] intel_sgx: TODO file for the staging area

In reply to Jarkko Sakkinen
Quoted 17 lines · Jarkko Sakkinen
drivers/staging/intel_sgx/TODO new file +11 -0
new file mode 100644
index 0000000..05f68c2
@@ -0,0 +1,25 @@
+Documentation
+=============
+
+* Improve Documents/x86/intel-sgx.txt based on the feedback and
+  questions that pop up.
+
+Internals
+=========
+
+* Move structures needed by the allocator to arch/x86/include/asm/sgx.h
+* Move EPC page allocation and eviction code to arch/x86/mm as they

drivers/staging/intel_sgx/TODO line 21

Quoted 10 lines
drivers/staging/intel_sgx/TODO new file +10 -0
+  will shared with virtualization code.
+* Move enclave management functions to arch/x86/mm as they will be
+  shared with virtualization code.
+* Use reserve_memtype() in order to add EPC to the PAT memtype list
+  with WB caching.
+* Implement proper recovery code for the pager for cases when
+  ETRACK/EBLOCK/EWB fails instead of BUG_ON(). Probably the sanest
+  way to recover is to clear TCS PTEs, kick threads out of enclave
+  and remove EPC pages.
+* Implement ACPI hot-lug for SGX.

- Write proper patch descriptions.

Especially how the "new VM" in 3/6 works needs a lot more explanation ...

- Add some test code

-Andi

#27 lore raw

Re: [PATCH 6/6] intel_sgx: TODO file for the staging area

Quoted 33 lines · Andi Kleen
Quoted 17 lines · Jarkko Sakkinen
drivers/staging/intel_sgx/TODO new file +11 -0
new file mode 100644
index 0000000..05f68c2
@@ -0,0 +1,25 @@
+Documentation
+=============
+
+* Improve Documents/x86/intel-sgx.txt based on the feedback and
+  questions that pop up.
+
+Internals
+=========
+
+* Move structures needed by the allocator to arch/x86/include/asm/sgx.h
+* Move EPC page allocation and eviction code to arch/x86/mm as they

drivers/staging/intel_sgx/TODO line 21

Quoted 10 lines
drivers/staging/intel_sgx/TODO new file +10 -0
+  will shared with virtualization code.
+* Move enclave management functions to arch/x86/mm as they will be
+  shared with virtualization code.
+* Use reserve_memtype() in order to add EPC to the PAT memtype list
+  with WB caching.
+* Implement proper recovery code for the pager for cases when
+  ETRACK/EBLOCK/EWB fails instead of BUG_ON(). Probably the sanest
+  way to recover is to clear TCS PTEs, kick threads out of enclave
+  and remove EPC pages.
+* Implement ACPI hot-lug for SGX.

- Write proper patch descriptions.

Quoted 1 line

Especially how the "new VM" in 3/6 works needs a lot more explanation ...

Agreed. I have now idea how to improve this given the feedback so far from you Andy and Greg. Thanks. It was hard to figure out the areas, which require more explanation before putting something out first.

Quoted 1 line

- Add some test code

Skylake, the only microarchitecture available at the moment supporting SGX, does not support IA32_SGXLEPUBKEYHASH* MSRs documented in Volume 3C of the Intel x86 SDM.

There will be an Open Source SDK available in the near future. It comes with Launch Enclave [1] that generates automatically EINITTOKENs for debug enclaves. At the moment there is no process for signing producton enclaves with the Intel root of trust for Linux (there is a process for Windows).

In order to write test code I would need to use the SDK at minimum to generate EINITTOKEN for the test enclave.

[1] The source code is available but with Skylake you cannot sign your own Launch Enclave binary, which is of course possible in future when the MSRs become available for having you own root of trust.

Quoted 1 line

-Andi

/Jarkko

#33 lore raw
In reply to Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#34 lore raw
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

Storing your ssh private key encrypted such that even someone who completely compromises your system can't get the actual private key out. Using this in conjunction with an RPMB device to make it Rather Difficult (tm) for third parties to decrypt your disk even if you password has low entropy. There are plenty more.

Think of this as the first time that a secure enclave will be widely available that anyone can program themselves. Well, almost: Skylake doesn't actually permit that for, ahem, reasons. But if you read the very most recent SDM update, it would appear that future Intel CPUs will allow this as long as the firmware doesn't get in the way. Look for IA32_SGXLEHASHSIG (possibly misspelled slightly -- the first few letters are correct).

--Andy

#35 lore raw
Quoted 12 lines · Andy Lutomirski
Quoted 11 lines · Pavel Machek
Quoted 9 lines · Jarkko Sakkinen

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

Quoted 4 lines
Quoted 1 line

What are non-evil use cases for this?

Storing your ssh private key encrypted such that even someone who completely compromises your system can't get the actual private key

Well, if someone gets root on my system, he can get my ssh private key.... right?

So, you can use this to prevent "cold boot" attacks? (You know, stealing machine, liquid nitrogen, moving DIMMs to different machine to read them?) Ok. That's non-evil.

Is there reason not to enable this for whole RAM if the hw can do it?

Quoted 3 lines

out. Using this in conjunction with an RPMB device to make it Rather Difficult (tm) for third parties to decrypt your disk even if you password has low entropy. There are plenty more.

I'm not sure what RPMB is, but I don't think you can make it too hard to decrypt my disk if my password has low entropy. ... And I don't see how encrypting RAM helps there.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#36 lore raw
Quoted 18 lines · Pavel Machek
Quoted 12 lines · Andy Lutomirski
Quoted 11 lines · Pavel Machek
Quoted 9 lines · Jarkko Sakkinen

Intel(R) 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.

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

Quoted 4 lines
Quoted 1 line

What are non-evil use cases for this?

Storing your ssh private key encrypted such that even someone who completely compromises your system can't get the actual private key

Quoted 6 lines

Well, if someone gets root on my system, he can get my ssh private key.... right?

So, you can use this to prevent "cold boot" attacks? (You know, stealing machine, liquid nitrogen, moving DIMMs to different machine to read them?) Ok. That's non-evil.

Preventing cold boot attacks is really just icing on the cake. The real point of this is to allow you to run an "enclave". An SGX enclave has unencrypted code but gets access to a key that only it can access. It could use that key to unwrap your ssh private key and sign with it without ever revealing the unwrapped key. No one, not even root, can read enclave memory once the enclave is initialized and gets access to its personalized key. The point of the memory encryption engine to to prevent even cold boot attacks from being used to read enclave memory.

This could probably be used for evil, but I think the evil uses are outweighed by the good uses.

Quoted 2 lines

Is there reason not to enable this for whole RAM if the hw can do it?

The HW can't, at least not in the current implementation. Also, the metadata has considerable overhead (no clue whether there's a performance hit, but there's certainly a memory usage hit).

Quoted 8 lines
Quoted 4 lines

out. Using this in conjunction with an RPMB device to make it Rather Difficult (tm) for third parties to decrypt your disk even if you password has low entropy. There are plenty more.

I'm not sure what RPMB is, but I don't think you can make it too hard to decrypt my disk if my password has low entropy. ... And I don't see how encrypting RAM helps there.

Replay Protected Memory Block. It's a device that allows someone to write to it and confirm that the write happened and the old contents is no longer available. You could use it to implement an enclave that checks a password for your disk but only allows you to try a certain number of times.

There are some hints in the whitepapers that such a mechanism might be present on existing Skylake chipsets. I'm not really sure.

Quoted 5 lines

Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Signature · 2 lines
Andy Lutomirski
AMA Capital Management, LLC
#37 lore raw

Hi!

Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

Storing your ssh private key encrypted such that even someone who completely compromises your system can't get the actual private key

Quoted 6 lines

Well, if someone gets root on my system, he can get my ssh private key.... right?

So, you can use this to prevent "cold boot" attacks? (You know, stealing machine, liquid nitrogen, moving DIMMs to different machine to read them?) Ok. That's non-evil.

Quoted 9 lines

Preventing cold boot attacks is really just icing on the cake. The real point of this is to allow you to run an "enclave". An SGX enclave has unencrypted code but gets access to a key that only it can access. It could use that key to unwrap your ssh private key and sign with it without ever revealing the unwrapped key. No one, not even root, can read enclave memory once the enclave is initialized and gets access to its personalized key. The point of the memory encryption engine to to prevent even cold boot attacks from being used to read enclave memory.

Ok, so the attacker can still access the "other" machine, but ok, key is protected.

But... that will mean that my ssh will need to be SGX-aware, and that I will not be able to switch to AMD machine in future. ... or to other Intel machine for that matter, right?

What new syscalls would be needed for ssh to get all this support?

Quoted 5 lines
Quoted 1 line

Is there reason not to enable this for whole RAM if the hw can do it?

The HW can't, at least not in the current implementation. Also, the metadata has considerable overhead (no clue whether there's a performance hit, but there's certainly a memory usage hit).

:-(.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

out. Using this in conjunction with an RPMB device to make it Rather Difficult (tm) for third parties to decrypt your disk even if you password has low entropy. There are plenty more.

I'm not sure what RPMB is, but I don't think you can make it too hard to decrypt my disk if my password has low entropy. ... And I don't see how encrypting RAM helps there.

Quoted 5 lines

Replay Protected Memory Block. It's a device that allows someone to write to it and confirm that the write happened and the old contents is no longer available. You could use it to implement an enclave that checks a password for your disk but only allows you to try a certain number of times.

Ookay... I guess I can get a fake Replay Protected Memory block, which will confirm that write happened and not do anything from China, but ok, if you put that memory on the CPU, you raise the bar to a "rather difficult" (tm) level. Nice.

But that also means that when my CPU dies, I'll no longer be able to access the encrypted data.

And, again, it means that quite complex new kernel-user interface will be needed, right?
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#47 lore raw
In reply to Andy Lutomirski
Quoted 5 lines

Replay Protected Memory Block. It's a device that allows someone to write to it and confirm that the write happened and the old contents is no longer available. You could use it to implement an enclave that checks a password for your disk but only allows you to try a certain number of times.

rpmb is found in a load of hardware today notably MMC/SD cards. Android phones often use it to store sensitive system data.

Alan

#48 lore raw
In reply to Pavel Machek
Quoted 5 lines
Quoted 2 lines

Storing your ssh private key encrypted such that even someone who completely compromises your system can't get the actual private key

Well, if someone gets root on my system, he can get my ssh private key.... right?

Potentially not. If you are using a TPM or other TEE (such as SGX) they can't because the authentication is done from within the TEE. They may be able to hack your box and use the TEE to login somewhere but not to get the key out.

Stopping the latter requires a TEE with its own secure input keypad (like some of the USB dongles)

Other uses might be things like keeping a copy of the rpm database so you can ask the TEE if the database you have right now happens to match the one you signed as authentic. I suspect there are lots of interesting things that can be done with dm_crypt and also IMA in this area too.

Alan

#38 lore raw
In reply to Pavel Machek
Quoted 3 lines

But... that will mean that my ssh will need to be SGX-aware, and that I will not be able to switch to AMD machine in future. ... or to other Intel machine for that matter, right?

I'm not privy to AMD's CPU design plans.

However I think for the ssl/ssh case you'd use the same interfaces currently available for plugging in TPMs and dongles. It's a solved problem in the crypto libraries.

Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

I don't see why you'd need new syscalls.

Quoted 2 lines

Ookay... I guess I can get a fake Replay Protected Memory block, which will confirm that write happened and not do anything from China, but

It's not quite that simple because there are keys and a counter involved but I am sure doable.

Quoted 2 lines

And, again, it means that quite complex new kernel-user interface will be needed, right?

Why ? For user space we have perfectly good existing system calls, for kernel space we have existing interfaces to the crypto and key layers for modules to use.

Alan

#39 lore raw
Quoted 6 lines · One Thousand Gnomes
Quoted 3 lines

But... that will mean that my ssh will need to be SGX-aware, and that I will not be able to switch to AMD machine in future. ... or to other Intel machine for that matter, right?

I'm not privy to AMD's CPU design plans.

Quoted 7 lines

However I think for the ssl/ssh case you'd use the same interfaces currently available for plugging in TPMs and dongles. It's a solved problem in the crypto libraries.

Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

I don't see why you'd need new syscalls.

So the kernel will implement few selected crypto algorithms, similar to what TPM would provide, using SGX, and then userspace no longer needs to know about SGX?

Ok, I guess that's simple.

It also means it is boring, and the multiuser-game-of-the-day will not be able to protect the (plain text) password from the cold boot attack.

Nor will be emacs be able to protect in-memory copy of my diary from cold boot attack.

So I guess yes, some new syscalls would be nice :-).
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#41 lore raw
In reply to Pavel Machek
Quoted 30 lines · Pavel Machek

Hi!

Quoted 17 lines
Quoted 10 lines
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

Storing your ssh private key encrypted such that even someone who completely compromises your system can't get the actual private key

Quoted 6 lines

Well, if someone gets root on my system, he can get my ssh private key.... right?

So, you can use this to prevent "cold boot" attacks? (You know, stealing machine, liquid nitrogen, moving DIMMs to different machine to read them?) Ok. That's non-evil.

Quoted 9 lines

Preventing cold boot attacks is really just icing on the cake. The real point of this is to allow you to run an "enclave". An SGX enclave has unencrypted code but gets access to a key that only it can access. It could use that key to unwrap your ssh private key and sign with it without ever revealing the unwrapped key. No one, not even root, can read enclave memory once the enclave is initialized and gets access to its personalized key. The point of the memory encryption engine to to prevent even cold boot attacks from being used to read enclave memory.

Quoted 6 lines

Ok, so the attacker can still access the "other" machine, but ok, key is protected.

But... that will mean that my ssh will need to be SGX-aware, and that I will not be able to switch to AMD machine in future. ... or to other Intel machine for that matter, right?

That's the whole point. You could keep an unwrapped copy of the key offline so you could provision another machine if needed.

Quoted 2 lines

What new syscalls would be needed for ssh to get all this support?

This patchset or similar, plus some user code and an enclave to use.

Sadly, on current CPUs, you also need Intel to bless the enclave. It looks like new CPUs might relax that requirement.

Quoted 23 lines
Quoted 6 lines
Quoted 2 lines

Is there reason not to enable this for whole RAM if the hw can do it?

The HW can't, at least not in the current implementation. Also, the metadata has considerable overhead (no clue whether there's a performance hit, but there's certainly a memory usage hit).

:-(.

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines

out. Using this in conjunction with an RPMB device to make it Rather Difficult (tm) for third parties to decrypt your disk even if you password has low entropy. There are plenty more.

I'm not sure what RPMB is, but I don't think you can make it too hard to decrypt my disk if my password has low entropy. ... And I don't see how encrypting RAM helps there.

Quoted 5 lines

Replay Protected Memory Block. It's a device that allows someone to write to it and confirm that the write happened and the old contents is no longer available. You could use it to implement an enclave that checks a password for your disk but only allows you to try a certain number of times.

Quoted 4 lines

Ookay... I guess I can get a fake Replay Protected Memory block, which will confirm that write happened and not do anything from China, but ok, if you put that memory on the CPU, you raise the bar to a "rather difficult" (tm) level. Nice.

It's not so easy for the RPMB to leak things. It would be much easier for it to simply not provide replay protection (i.e. more or less what the FBI asked from Apple: keep allowing guesses even though that shouldn't work).

Quoted 3 lines

But that also means that when my CPU dies, I'll no longer be able to access the encrypted data.

You could implement your own escrow policy and keep a copy in the safe.

Quoted 3 lines

And, again, it means that quite complex new kernel-user interface will be needed, right?

It's actually fairly straightforward, and the kernel part doesn't care what you use it for (the kernel part is the same for disk encryption and ssh, for example, except that disk encryption would care about replay protection, whereas ssh wouldn't).

--Andy

#40 lore raw
In reply to Pavel Machek
Quoted 11 lines · Pavel Machek
Quoted 10 lines · One Thousand Gnomes
Quoted 3 lines

But... that will mean that my ssh will need to be SGX-aware, and that I will not be able to switch to AMD machine in future. ... or to other Intel machine for that matter, right?

I'm not privy to AMD's CPU design plans.

However I think for the ssl/ssh case you'd use the same interfaces currently available for plugging in TPMs and dongles. It's a solved problem in the crypto libraries.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

I don't see why you'd need new syscalls.

So the kernel will implement few selected crypto algorithms, similar to what TPM would provide, using SGX, and then userspace no longer needs to know about SGX?

No, other way around. The kernel will provide a basic interface to SGX and userspace can do whatever it wants. If userspace wants to use RSA, userspace will provide an actual RSA implementation, in more or less normal x86 binary form, and will map it into user addresses. It will tell the kernel "hey, this address range is an enclave", and the kernel will set it up as such and tell the CPU about it. Userspace will then use SGX instructions to communicate with the enclave.

It's pretty neat, and it's completely agnostic to the purpose of the enclave.

--Andy

#8 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jarkko Sakkinen

Review

Quoted 1 line · Jarkko Sakkinen
(quoted diff) +0 -0

b/drivers/staging/intel_sgx/isgx_ioctl.c

drivers/staging/intel_sgx/isgx_ioctl.c line 341

Quoted 11 lines

new file mode 100644
index 0000000..9d8b36b

drivers/staging/intel_sgx/isgx_ioctl.c new file +5 -0
 
+static long isgx_ioctl_enclave_create(struct file *filep, unsigned int cmd,
+ unsigned long arg)
 
+ secs->base = vm_mmap(filep, 0, secs->size,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED, 0);

Why does the ioctl interface map userspace memory for an open device? There's already a perfectly good syscall for that: mmap.

Quoted 5 lines
drivers/staging/intel_sgx/isgx_user.h new file +0 -0
new file mode 100644
index 0000000..672d19c

drivers/staging/intel_sgx/isgx_user.h line 101

Quoted 9 lines
drivers/staging/intel_sgx/isgx_user.h new file +8 -0
 
+#define SGX_ADD_SKIP_EEXTEND 0x1
+
+struct sgx_add_param {
+	unsigned long		addr;
+	unsigned long		user_addr;
+	struct isgx_secinfo	*secinfo;
+	unsigned int		flags;
+};

The hardware supports calling EEXTEND on only a part of a page, I think the driver should also support that.

Jethro

#42 lore raw
In reply to Andy Lutomirski

Hi!

Quoted 21 lines
Quoted 10 lines
Quoted 9 lines

Preventing cold boot attacks is really just icing on the cake. The real point of this is to allow you to run an "enclave". An SGX enclave has unencrypted code but gets access to a key that only it can access. It could use that key to unwrap your ssh private key and sign with it without ever revealing the unwrapped key. No one, not even root, can read enclave memory once the enclave is initialized and gets access to its personalized key. The point of the memory encryption engine to to prevent even cold boot attacks from being used to read enclave memory.

Quoted 6 lines

Ok, so the attacker can still access the "other" machine, but ok, key is protected.

But... that will mean that my ssh will need to be SGX-aware, and that I will not be able to switch to AMD machine in future. ... or to other Intel machine for that matter, right?

That's the whole point. You could keep an unwrapped copy of the key offline so you could provision another machine if needed.

Quoted 1 line
Quoted 6 lines
Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

This patchset or similar, plus some user code and an enclave to use.

Sadly, on current CPUs, you also need Intel to bless the enclave. It looks like new CPUs might relax that requirement.

Umm. I'm afraid my evil meter just went over "smells evil" and "bit evil" areas straight to "certainly looks evil".

Quoted 11 lines
Quoted 10 lines
Quoted 5 lines

Replay Protected Memory Block. It's a device that allows someone to write to it and confirm that the write happened and the old contents is no longer available. You could use it to implement an enclave that checks a password for your disk but only allows you to try a certain number of times.

Ookay... I guess I can get a fake Replay Protected Memory block, which will confirm that write happened and not do anything from China, but ok, if you put that memory on the CPU, you raise the bar to a "rather difficult" (tm) level. Nice.

Quoted 4 lines

It's not so easy for the RPMB to leak things. It would be much easier for it to simply not provide replay protection (i.e. more or less what the FBI asked from Apple: keep allowing guesses even though that shouldn't work).

Yup.

Quoted 5 lines
Quoted 2 lines

But that also means that when my CPU dies, I'll no longer be able to access the encrypted data.

You could implement your own escrow policy and keep a copy in the safe.

And then Intel would have to bless my own escrow policy, which is, realistically, not going to happen, right?

Quoted 7 lines
Quoted 2 lines

And, again, it means that quite complex new kernel-user interface will be needed, right?

It's actually fairly straightforward, and the kernel part doesn't care what you use it for (the kernel part is the same for disk encryption and ssh, for example, except that disk encryption would care about replay protection, whereas ssh wouldn't).

So we end up with parts of kernel we can not change, and where we may not even change the compiler. That means assembly. Hey, user, you have freedom to this code, except it will not work. That was called TiVo before. We'd have security-relevant parts of kernel where we could not even fix a securit holes without Intel.

If anything, this is reason to switch to GPLv3.

I'm sorry. This is evil.

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#43 lore raw
In reply to Andy Lutomirski
Quoted 6 lines · Andy Lutomirski
Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

This patchset or similar, plus some user code and an enclave to use.

Sadly, on current CPUs, you also need Intel to bless the enclave. It looks like new CPUs might relax that requirement.

That looks like a fundamental technical limitation in my book - to an open source user this is essentially a very similar capability as tboot: it only allows the execution of externally blessed static binary blobs...

I don't think we can merge any of this upstream until it's clear that the hardware owner running open-source user-space can also freely define/start his own secure enclaves without having to sign the enclave with any external party. I.e. self-signed enclaves should be fundamentally supported as well.

Thanks,

Ingo

#9 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jethro Beekman
Quoted 11 lines · Jethro Beekman

Review

Quoted 1 line · Jarkko Sakkinen
(quoted diff) +0 -0

b/drivers/staging/intel_sgx/isgx_ioctl.c

Quoted 8 lines

new file mode 100644
index 0000000..9d8b36b

drivers/staging/intel_sgx/isgx_ioctl.c new file +2 -0
 
+static long isgx_ioctl_enclave_create(struct file *filep, unsigned int cmd,
+ unsigned long arg)
Quoted 6 lines
Quoted 3 lines

+ secs->base = vm_mmap(filep, 0, secs->size,
+ PROT_READ | PROT_WRITE | PROT_EXEC,
+ MAP_SHARED, 0);

Why does the ioctl interface map userspace memory for an open device? There's already a perfectly good syscall for that: mmap.

You didn't explain what would be the value in doing this but after thinking for a short while I found out two good reasons:

* The current API is ugly in a way that you can anyway call mmap directly too and have a useless zombie enclave. This would make the API less ambiguous.
* SGX_IOC_ENCLAVE_CREATE could be removed. SECS could be passed through SGX_IOC_ENCLAVE_ADD_PAGE thus simplifying the API a lot.

Given these circumstances I think this does make sense.

Quoted 6 lines
Quoted 6 lines
drivers/staging/intel_sgx/isgx_user.h new file +0 -0
new file mode 100644
index 0000000..672d19c
Quoted 11 lines

drivers/staging/intel_sgx/isgx_user.h line 101

Quoted 8 lines
drivers/staging/intel_sgx/isgx_user.h new file +8 -0
+#define SGX_ADD_SKIP_EEXTEND 0x1
+
+struct sgx_add_param {
+	unsigned long		addr;
+	unsigned long		user_addr;
+	struct isgx_secinfo	*secinfo;
+	unsigned int		flags;
+};

The hardware supports calling EEXTEND on only a part of a page, I think the driver should also support that.

Why would you want to do that?

Quoted 1 line

Jethro

/Jarkko

#44 lore raw
In reply to Ingo Molnar
Quoted 11 lines · Ingo Molnar
Quoted 6 lines · Andy Lutomirski
Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

This patchset or similar, plus some user code and an enclave to use.

Sadly, on current CPUs, you also need Intel to bless the enclave. It looks like new CPUs might relax that requirement.

Quoted 8 lines

That looks like a fundamental technical limitation in my book - to an open source user this is essentially a very similar capability as tboot: it only allows the execution of externally blessed static binary blobs...

I don't think we can merge any of this upstream until it's clear that the hardware owner running open-source user-space can also freely define/start his own secure enclaves without having to sign the enclave with any external party. I.e. self-signed enclaves should be fundamentally supported as well.

Certainly, if this were a *graphics* driver, airlied would refuse to merge it without open source userspace available.

We're all used to Intel sending patches that no one outside Intel can test without because no one has the hardware. Heck, I recently sent a vdso patch that *I* can't test. But in this case I have the hardware and there is no way that I can test it, and I don't like this at all.

See my earlier comments about not allowing user code to provide EINITTOKEN. Implementing that would mostly solve this problem, with the big caveat that it may be impossible to implement that suggestion until Intel changes its stance (which is clearly in progress, given the recent SDM updates).

This could easily end up bring a CNL-only feature in Linux. (Or whatever generation that change is in.)

--Andy

#10 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jarkko Sakkinen
Quoted 4 lines · Jarkko Sakkinen
Quoted 2 lines

The hardware supports calling EEXTEND on only a part of a page, I think the driver should also support that.

Why would you want to do that?

You might have segments in a binary that don't start at the beginning of a page or that end before the end of a page. For example:

Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000

                 0x000000000001bcac 0x000000000001bcac  R E    1000
  LOAD           0x000000000001c8e8 0x000000000001c8e8 0x000000000001c8e8
                 0x0000000000000790 0x0000000000000c68  RW     1000

There's no need to measure the extra padding (0x1bd00--0x1c7ff and 0x1cb00--0x1cfff) in this case.

Quoted 1 line

/Jarkko

Jethro

#11 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

Quoted 12 lines · Jethro Beekman
Quoted 4 lines · Jarkko Sakkinen
Quoted 2 lines

The hardware supports calling EEXTEND on only a part of a page, I think the driver should also support that.

Why would you want to do that?

You might have segments in a binary that don't start at the beginning of a page or that end before the end of a page. For example:

Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000

Quoted 6 lines
                 0x000000000001bcac 0x000000000001bcac  R E    1000
  LOAD           0x000000000001c8e8 0x000000000001c8e8 0x000000000001c8e8
                 0x0000000000000790 0x0000000000000c68  RW     1000

There's no need to measure the extra padding (0x1bd00--0x1c7ff and 0x1cb00--0x1cfff) in this case.

Do you see this as a performance issue or why do you think that this would hurt that much?

Quoted 1 line

Jethro

/Jarkko

#49 lore raw
In reply to Pavel Machek
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

Quoted 6 lines

Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

/Jarkko

#70 lore raw
In reply to Pavel Machek
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

Virtual TPMs for containers/guests would be one such use case.

/Jarkko

#12 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jarkko Sakkinen
Quoted 6 lines · Jarkko Sakkinen
Quoted 3 lines
Quoted 1 line

Why would you want to do that?

...

Do you see this as a performance issue or why do you think that this would hurt that much?

I don't think it's a performance issue at all. I'm just giving an example of why you'd want to do this. I'm sure people who want to use this instruction set can come up with other uses, so I think the driver should support it. Other drivers on different platform might support this, in which case we should be compatible (to achieve the same enclave measurement). Other Linux drivers support it [1]. I would ask: why would you not want to do this? It seems trivial to expand the current flag into 16 separate flags; one for each 256-byte chunk in the page.

[1] https://github.com/jethrogb/sgx-utils/tree/master/linux-driver

Quoted 1 line

/Jarkko

Jethro

#71 lore raw
In reply to Jarkko Sakkinen

Hi!

Quoted 10 lines · Jarkko Sakkinen
Quoted 7 lines · Pavel Machek
Quoted 4 lines · Jarkko Sakkinen

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

Well, that's kind of hard to explain.

Quoted 3 lines
Quoted 1 line

What are non-evil use cases for this?

Virtual TPMs for containers/guests would be one such use case.

..but as long as Intel has to sign each piece of software so that it can use SGX, it is unsuitable for Linux kernel.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#50 lore raw
In reply to Jarkko Sakkinen
Quoted 7 lines · Jarkko Sakkinen
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

I would think that this should be pretty straightforward. Pretty much every security technology integrated in every computer in existence has the potential to be used by malware for various purposes. Based on a cursory look at SGX, it is pretty easy to figure out how to use this to hide arbitrary code from virus scanners and the OS itself unless you have some way to force everything to be a debug enclave, which entirely defeats the stated purpose of the extensions. I can see this being useful for tight embedded systems. On a desktop which I have full control of physical access to though, it's something I'd immediately turn off, because the risk of misuse is so significant (I've done so on my new Thinkpad L560 too, although that's mostly because Linux doesn't support it yet).

#51 lore raw

On May 2, 11:37am, "Austin S. Hemmelgarn" wrote:
} Subject: Re: [PATCH 0/6] Intel Secure Guard Extensions

Good morning, I hope the day is starting out well for everyone.

Quoted 17 lines · Jarkko Sakkinen
Quoted 7 lines · Pavel Machek
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines

Intel(R) 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.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

Quoted 13 lines

I would think that this should be pretty straightforward. Pretty much every security technology integrated in every computer in existence has the potential to be used by malware for various purposes. Based on a cursory look at SGX, it is pretty easy to figure out how to use this to hide arbitrary code from virus scanners and the OS itself unless you have some way to force everything to be a debug enclave, which entirely defeats the stated purpose of the extensions. I can see this being useful for tight embedded systems. On a desktop which I have full control of physical access to though, it's something I'd immediately turn off, because the risk of misuse is so significant (I've done so on my new Thinkpad L560 too, although that's mostly because Linux doesn't support it yet).

We were somewhat surprised to see Intel announce the SGX driver for Linux without a bit more community preparation given the nature of the technology. But, given the history of opacity around this technology, it probably isn't surprising. We thought it may be useful to offer a few thoughts on this technology as discussion around integrating the driver moves forward.

We have been following and analyzing this technology since the first HASP paper was published detailing its development. We have been working to integrate, at least at the simulator level, portions of this technology in solutions we deliver. We have just recently begun to acquire validated reference platforms to test these implementations.

I told my associates the first time I reviewed this technology that SGX has the ability to be a bit of a Pandora's box and it seems to be following that course.

SGX belongs to a genre of solutions collectively known as Trusted Execution Environments (TEE's). The intent of these platforms is to support data and application confidentiality and integrity in the face of an Iago threat environment, ie. a situation where a security aggressor has complete control of the hardware and operating system, up to and including the OS 'lying' about what it is doing to the application.

There are those, including us, who question the quality of the security gurantee that can be provided but that doesn't diminish the usefulness or demand for such technology. If one buys the notion that all IT delivery will move into the 'cloud' there is certainly a rationale for a guarantee that clients can push data into a cloud without concern for whether or not the platform is compromised or being used to spy on the user's application or data.

As is the case with any security technology, the only way that such a guarantee can be made is to have a definable origin or root of trust. At the current time, and this may be the biggest problem with SGX, the only origin for that root of trust is Intel itself. Given the nature and design of SGX this is actually a bilateral root of trust since Intel, by signing a developer's enclave key, is trusting the developer to agree to do nothing nefarious while being shrouded by the security guarantee that SGX provides.

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

Which details what a developer is required to do in order to obtain an enclave signing key which will be recognized by an SGX capable
processor. Without a valid signing key an SGX capable system will
only launch an enclave in 'debug' mode which allows the enclave to be single stepped and examined in a debugger, which obviously invalidates any TEE based security guarantees which SGX is designed to effect.

Intel is obviously cognizant of the risk surrounding illicit uses of this technology since it clearly calls out that, by agreeing to have their key signed, a developer agrees to not implement nefarious or privacy invasive software. Given the known issues that Certificate Authorities have with validating certificate recipients the security guarantee inherent in such an agreement is questionable.

So, giving Intel the benefit of the doubt, the licensing issues surrounding SGX is probably more about cognizance of the security risk associated with the technology rather then a quest for world domination and control. They probably have enough on their hands with attempting to convert humanity to FPGA's and away from devices which are capable of maintaining a context of exection... :-)

The much bigger debate is about the utility of the security guarantee inherent in SGX. Anyone who is interested in understanding all of the issues surrounding this technology would do well to start by reading the Haven paper in which Microsoft Research discussed how SGX could be used to run unmodified Windows applications within an SGX TEE.

I think Intel was somewhat sobered by the follow on paper in which Microsoft demonstrated that in an Iago environment an interloper was capable of determing with accuracy levels greater then 60% what was being done in an SGX TEE. Matt Hoekstra was very quick to call out the need for the community to understand and develop side channel remediation strategies which anyone familiar with the field would have anticipated to be the primary threat to attempting to induct security into a completely insecure environment.

One of the participants in the thread suggested that one of the 'non-evil' uses of this technology would be to run virtual machines and by extensions containers. It is pretty obvious at this point that Intel has shifted to advocating limiting the scope of SGX to providing protection to isolated applications and data, think password managers, rather then as a wholesale execution shroud. That is the role we have leveraged SGX for in our security supervisor.

At the end of the day it is very, very difficult to give up complete platform control and maintain integrity and confidentiality guarantees about an application and the data it is operating on. With its recent re-organization Intel is obviously going to be heavily focused on the cloud and the the notion of TEE's are seductive, particularly for data in which there is no ex-post-facto regress in the face of compromise.

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

This note is probably a study in TL;DR but this technology is not inherently evil nor a ubiquitous security solution. It is simply another arrow in the quiver and as Satya Nadella from Microsoft has pointed out, the mess we have gotten ourselves in is not going to be amenable to a simple or single fix.

In the TL;DR department I would highly recommend that anyone interested in all of this read MIT's 170+ page review of the technology before jumping to any conclusions.... :-)

Best wishes for a productive week.

Greg

}-- End of excerpt from "Austin S. Hemmelgarn"

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: [email protected]
------------------------------------------------------------------------------
"If you plugged up your nose and mouth right before you sneezed, would
the sneeze go out your ears or would your head explode? Either way I'm afraid to try."
-- Nick Kean

#52 lore raw

Hi!

Quoted 2 lines

We have been following and analyzing this technology since the first HASP paper was published detailing its development. We have been

(1)

Quoted 4 lines

I told my associates the first time I reviewed this technology that SGX has the ability to be a bit of a Pandora's box and it seems to be following that course.

Can you elaborate on the Pandora's box? System administrator should be able to disable SGX on the system, and use system to do anything that could be done with the older CPUs, right?

Quoted 2 lines

support data and application confidentiality and integrity in the face of an Iago threat environment, ie. a situation where a security

(2)

Quoted 4 lines

Intel is obviously cognizant of the risk surrounding illicit uses of this technology since it clearly calls out that, by agreeing to have their key signed, a developer agrees to not implement nefarious or privacy invasive software. Given the known issues that Certificate

Yeah, that's likely to work ... not :-(. "It is not spyware, it is just collecting some anonymous statistics."

Quoted 3 lines

domination and control. They probably have enough on their hands with attempting to convert humanity to FPGA's and away from devices which are capable of maintaining a context of exection... :-)

Heh. FPGAs are not designed to replace CPUs anytime soon... And probably never.

Quoted 2 lines

the Haven paper in which Microsoft Research discussed how SGX could be used to run unmodified Windows applications within an SGX TEE.

(3)

Quoted 5 lines

I think Intel was somewhat sobered by the follow on paper in which Microsoft demonstrated that in an Iago environment an interloper was capable of determing with accuracy levels greater then 60% what was being done in an SGX TEE. Matt Hoekstra was very quick to call out the need for the community to understand and develop side channel

(4)

Quoted 3 lines

In the TL;DR department I would highly recommend that anyone interested in all of this read MIT's 170+ page review of the technology before jumping to any conclusions.... :-)

(5)

Would you have links for 1-5?

Thanks,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#53 lore raw
Quoted 1 line · Pavel Machek

Hi!

Good morning, I hope everyone's day is starting out well.

Quoted 7 lines
Quoted 3 lines

I told my associates the first time I reviewed this technology that SGX has the ability to be a bit of a Pandora's box and it seems to be following that course.

Can you elaborate on the Pandora's box? System administrator should be able to disable SGX on the system, and use system to do anything that could be done with the older CPUs, right?

Correct, there is certainly the on/off switch.

I viewed it as a Pandora's box secondary to the fact that it was the first commodity based shrouded TEE that had the opportunity for significant market penetration. As such and secondary to its technical characteristics, it has the potential for both good and bad and like TXT in the last decade it was/is bound to induce significant debate secondary to software freedom and potential monopolistic practices.

Quoted 7 lines
Quoted 4 lines

Intel is obviously cognizant of the risk surrounding illicit uses of this technology since it clearly calls out that, by agreeing to have their key signed, a developer agrees to not implement nefarious or privacy invasive software. Given the known issues that Certificate

Yeah, that's likely to work ... not :-(. "It is not spyware, it is just collecting some anonymous statistics."

The notion that an enclave can look out but could not be looked into introduces privacy issues into the conversation, see my reflections on Pandoras box... :-)

Quoted 6 lines
Quoted 3 lines

domination and control. They probably have enough on their hands with attempting to convert humanity to FPGA's and away from devices which are capable of maintaining a context of exection... :-)

Heh. FPGAs are not designed to replace CPUs anytime soon... And probably never.

Never is a long time.

Intel has clearly drawn a very significant line in the sand with respect to FPGA technology if you read Krzanich's reflections regarding his re-organization of Intel. Whether or not they are successful, they are going to declare a demarcation point with respect to IOT devices which has the potential to impact the industry in general and security in particular. On one side are going to be FPGA based devices and on the other side devices with a context of execution.

I doesn't require a long stretch of the imagination to see hordes of IOT devices with specific behaviors burned into them which export sensor or telemetry data upstream. Depending on how successful they are with the Altera acquisition there are potentially positive economic security factors which could be in play.

All of that is certainly not a conversation specific to SGX though.

Quoted 5 lines
Quoted 3 lines

In the TL;DR department I would highly recommend that anyone interested in all of this read MIT's 170+ page review of the technology before jumping to any conclusions.... :-)

Would you have links for 1-5?

First off my apologies to the list as I loathe personal inaccuracy, the MIT review paper is only 117 pages long. I was typing the last e-mail at 0405 in the morning and was scrambling for the opportunity to get 50 minutes of sleep so my proofreading was sloppy... :-)

The following should provide ample bedstand reading material for those interested in SGX and TEE's:

1.) HASP/SGX paper:
https://software.intel.com/sites/default/files/article/413939/hasp-2013-innovative-technology-for-attestation-and-sealing.pdf

2.) IAGO threat model:
https://cseweb.ucsd.edu/~hovav/dist/iago.pdf

3.) Haven paper:
http://research.microsoft.com/pubs/223450/osdi2014-haven.pdf

4.) Controlled sidechannel attacks:
http://research.microsoft.com/pubs/246400/ctrlchannels-oakland-2015.pdf

https://software.intel.com/en-us/blogs/2015/05/19/look-both-ways-and-watch-out-for-side-channels

5.) MIT/SGX analysis:
https://eprint.iacr.org/2016/086.pdf

Quoted 2 lines

Thanks,
Pavel

No problem, enjoy the reading.... :-)

Have a good day.

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: [email protected]
------------------------------------------------------------------------------
"One problem with monolithic business structures is losing sight
of the fundamental importance of mathematics. Consider committees; commonly forgotten is the relationship that given a projection of N individuals to complete an assignment the most effective number of people to assign to the committee is given by f(N) = N - (N-1)."
-- Dr. G.W. Wettstein
Guerrilla Tactics for Corporate Survival

#54 lore raw

Hi!

Quoted 1 line

Good morning, I hope everyone's day is starting out well.

:-). Rainy day here.

Quoted 10 lines
Quoted 5 lines
Quoted 3 lines

In the TL;DR department I would highly recommend that anyone interested in all of this read MIT's 170+ page review of the technology before jumping to any conclusions.... :-)

Would you have links for 1-5?

First off my apologies to the list as I loathe personal inaccuracy, the MIT review paper is only 117 pages long. I was typing the last e-mail at 0405 in the morning and was scrambling for the opportunity to get 50 minutes of sleep so my proofreading was sloppy... :-)

Thanks a lot for the links, I'd still say it was more accurate than average for the lkml.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#18 lore raw

Re: [PATCH 5/6] intel_sgx: driver documentation

In reply to Andy Lutomirski
Quoted 11 lines · Andy Lutomirski

Documentation/x86/intel_sgx.txt line 86

Quoted 7 lines · Jarkko Sakkinen
Documentation/x86/intel_sgx.txt new file +6 -0
+SGX_IOCTL_ENCLAVE_INIT
+
+Initializes an enclave given by SIGSTRUCT and EINITTOKEN. Executes EINIT leaf
+instruction that will check that the measurement matches the one SIGSTRUCT and
+EINITTOKEN. EINITTOKEN is a data blob given by a special enclave called Launch
+Enclave and it is signed with a CPU's Launch Key.

Having thought about this for ten minutes, I have the following thought:

Quoted 6 lines

I think that we should seriously consider not allowing user code to supply EINITTOKEN at all. Here's why:

1. The nominal purpose of this thing is "launch control." I think that the decision of whether to launch an enclave belongs in the kernel to the extent that the kernel has the ability to control this.

I'm not sure why you would want to do this especially when you can use your own key pair for launch control in future.

This would degrade the security of the SGX to the level of the running kernel binary.

Quoted 8 lines

2. I think that launch control is actively insecure (assuming that the use case is what I think it is). Since the kernel might have some interest in controlling whether an enclave can launch (I think this is entirely reasonable) and since that policy might reasonably be expressed in the form of a launch enclave, I think that the *kernel* should generate the actual EINITTOKEN object. (I also reported, off-list, what I think is a significant security issue under some usage models that is mitigated if the user isn't allowed to supply their own EINITTOKEN of unknown provenance.)

Generating EINITTOKEN requires to have a launch enclave i.e. enclave that is signed with the private key of the launch control policy.

Quoted 10 lines

3. On a CPU with unlocked IA32_SGXLEPUBKEYHASH, I think that the kernel should ship, *in the kernel image*, a binary corresponding to an open-source "launch anything" enclave. The kernel should, when appropriate, use this thing to generate EINITTOKEN objects. User code should *not* have to think about where this "launch anything" enclave comes from or whether it's the same on all kernels. (I think that the best way to do this would be to try to build it deterministically using a well-known key pair. This should be very easy to do.) If someone wants to turn this feature off, let them do so via sysctl.

Quoted 7 lines

If someone wants to supply their own launch enclave, then let them either feed it to the kernel or enable some non-default privileged option to allow them to supply EINITTOKEN directly.

Actually implementing this is going to be interesting, because the kernel will have to call out to CPL 3 to do it. It's not *that* hard, though, as the exiting kernel thread API should be more or less adequate.

I think that the key point is that you can define your own key pair in order to have your own launch control policy. This will be eventually enabled as it is documented in the SDM.

Quoted 1 line

--Andy

/Jarkko

#67 lore raw
In reply to Austin S. Hemmelgarn
Quoted 17 lines · Austin S. Hemmelgarn
Quoted 7 lines · Jarkko Sakkinen
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

Quoted 11 lines

I would think that this should be pretty straightforward. Pretty much every security technology integrated in every computer in existence has the potential to be used by malware for various purposes. Based on a cursory look at SGX, it is pretty easy to figure out how to use this to hide arbitrary code from virus scanners and the OS itself unless you have some way to force everything to be a debug enclave, which entirely defeats the stated purpose of the extensions. I can see this being useful for tight embedded systems. On a desktop which I have full control of physical access to though, it's something I'd immediately turn off, because the risk of misuse is so significant (I've done so on my new Thinkpad L560 too, although that's mostly because Linux doesn't support it yet).

The code in enclave binary is in clear text so it does not really allow you to completely hide any code. It's a signed binary, not encypted binary.

/Jarkko

#19 lore raw

Re: [PATCH 5/6] intel_sgx: driver documentation

In reply to Jarkko Sakkinen
Quoted 15 lines · Jarkko Sakkinen
Quoted 14 lines · Andy Lutomirski

Documentation/x86/intel_sgx.txt line 86

Quoted 7 lines · Jarkko Sakkinen
Documentation/x86/intel_sgx.txt new file +6 -0
+SGX_IOCTL_ENCLAVE_INIT
+
+Initializes an enclave given by SIGSTRUCT and EINITTOKEN. Executes EINIT leaf
+instruction that will check that the measurement matches the one SIGSTRUCT and
+EINITTOKEN. EINITTOKEN is a data blob given by a special enclave called Launch
+Enclave and it is signed with a CPU's Launch Key.

Having thought about this for ten minutes, I have the following thought:

I think that we should seriously consider not allowing user code to supply EINITTOKEN at all. Here's why:

Quoted 6 lines
Quoted 3 lines

1. The nominal purpose of this thing is "launch control." I think that the decision of whether to launch an enclave belongs in the kernel to the extent that the kernel has the ability to control this.

I'm not sure why you would want to do this especially when you can use your own key pair for launch control in future.

Here are my thoughts. There are a few ways the system (firmware, MSR, and Intel policy) could be configured:

+++ status quo +++

Applications that ship enclaves come bundled with signatures and possibly certificate chains. They call into some SDK API to request launch permission. The SDK says "ok". Then the application asks the SDK to launch it. It's entirely unclear to me how Intel distributes the LE versions that make this work on Windows. I'm guessing they're bundled in the SDK, but for all I know, they're in the kernel.

I think that Linux should possibly refuse to support this mode upstream. If Linux were to support it, then it might actually match ISV-expected behavior better if the LE was bundled with the kernel -- after all, the ISV already has very little visibility into where the LE comes from, and it seems more like a system policy thing.

+++ current Skylakes with hypothetical Intel "launch anything" policy +++

If the combination of Intel policy and firmware configuration were to allow anything to launch, then the OS should either impose its own policy or allow anything to launch. I can easily imagine the implementation of this involving a channel by which the kernel proves to the LE that firmware/platform config is intended to allow "launch anything". In this case, I think this belongs either in the kernel or in a privileged daemon, and putting it in the kernel is probably much more straightforward. In any event, applications shouldn't need to worry about the nitty gritty details of where exactly their EINITTOKEN comes from.

+++ future chips with unlocked IA32_SGXLEPUBKEYHASH +++

The firmware policy really is "launch anything" in this case, and it's the kernel's job to restrict that further if it likes (by programming the MSRs and/or filtering EINIT). I think that the most natural way to implement this would be for the kernel to implement whatever policy it likes and to either ship an LE that accepts anything as part of the kernel image that's signed by a key where everyone knows the *private* key or to generate a random key pair at build time, build the enclave along with the kernel, and include the public key and the LE in the kernel image. In either case, I don't think that apps should need to ship this special LE -- the kernel should handle it.

If admins want to impose additional launch policy, then by all means Linux should offer that. I'm just not at all convinced that fiddling with the MSRs in new and complicated ways is the right way to do that -- I think the kernel should implement more advanced policy by filtering EINIT.

Keep in mind that, if the kernel is compromised, then the attacker can launch anything no matter what the kernel tries to do because the attacker controls the MSRs.

+++ future chips with IA32_SGXLEPUBKEYHASH set to a non-default value +++

I don't see a valid use case for this other than snake oil. One may well exist, but, if so, it hasn't been explained to me. If someone comes up with one, then, by all means, we could support it in the kernel. Nonetheless, an SGX-aware app that is designed to work under the status quo policy or in a "launch anything" regime should still work if the special local policy intends for it to work, and I don't think that app should need to possess a copy of the bespoke signed LE in order to function. IOW, to allow the same app to run here if policy is okay with it, I think we *have* to delegate EINITTOKEN generation to something other than the SGX-using app.

My intuition is that either the Windows approach to this is going to end up being a mess and very unpleasant for ISVs to work with or that Windows will move to a configuration in which EINITTOKEN generation is delegated to the kernel or to a privileged daemon that ships with the OS. I think that Linux should do that as well to avoid unpleasantness. If Linux ends up being easier to develop SGX applications on than Windows, then that's means that Linux did something right.

Also, in the unlocked-MSR case, I think that the kernel *must* implement EINIT filtering. The kernel should not allow an untrusted LE to run, because that LE might leak the raw EGETKEY output to a malicious party, and the implications of that might not be so nice. This is yet another argument in favor of having the kernel supply the LE so that the kernel can trust the LE. (Obviously, extracting raw *debug* EGETKEY output is possible even on Windows on current systems, but that raw output isn't particularly useful.)

Quoted 3 lines

This would degrade the security of the SGX to the level of the running kernel binary.

How so? SGX is supposed to be secure even under the assumption that anyone can launch anything they want and even under the assumption that the kernel is malicious. If SGX fails at that, then it would be odd to blame kernel policy for that.

--Andy

#68 lore raw
In reply to Jarkko Sakkinen
Quoted 30 lines · Jarkko Sakkinen
Quoted 17 lines · Austin S. Hemmelgarn
Quoted 7 lines · Jarkko Sakkinen
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

Quoted 11 lines

I would think that this should be pretty straightforward. Pretty much every security technology integrated in every computer in existence has the potential to be used by malware for various purposes. Based on a cursory look at SGX, it is pretty easy to figure out how to use this to hide arbitrary code from virus scanners and the OS itself unless you have some way to force everything to be a debug enclave, which entirely defeats the stated purpose of the extensions. I can see this being useful for tight embedded systems. On a desktop which I have full control of physical access to though, it's something I'd immediately turn off, because the risk of misuse is so significant (I've done so on my new Thinkpad L560 too, although that's mostly because Linux doesn't support it yet).

Quoted 3 lines

The code in enclave binary is in clear text so it does not really allow you to completely hide any code. It's a signed binary, not encypted binary.

Umm. Now you are evil.

Yes, the code that starts in the enclave may not be encrypted, but I'm pretty sure the enclave will download some more code from remote server after attestation... x86 or some kind of interpretted code.

(But of course we already know that the technology is evil, as only Intel can use it, see Ingo's reply.)
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#45 lore raw
In reply to Ingo Molnar
Quoted 10 lines · Ingo Molnar
Quoted 6 lines · Andy Lutomirski
Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

This patchset or similar, plus some user code and an enclave to use.

Sadly, on current CPUs, you also need Intel to bless the enclave. It looks like new CPUs might relax that requirement.

Quoted 8 lines

That looks like a fundamental technical limitation in my book - to an open source user this is essentially a very similar capability as tboot: it only allows the execution of externally blessed static binary blobs...

I don't think we can merge any of this upstream until it's clear that the hardware owner running open-source user-space can also freely define/start his own secure enclaves without having to sign the enclave with any external party. I.e. self-signed enclaves should be fundamentally supported as well.

Post Skylake we will have a set of MSRs for defining your own root of
trust: IA32_SGXLEPUBKEYHASH.

Andy had a concern that you could set root of trust multiple times, which could lead to potential attack scenarios. These MSRs are one-shot. ENCLS will fail if the launch control is locked. There's no possiblity to have a root of trust that is unlocked.

Quoted 3 lines

Thanks,

Ingo

/Jarkko

#69 lore raw
In reply to Pavel Machek
Quoted 35 lines · Pavel Machek
Quoted 30 lines · Jarkko Sakkinen
Quoted 17 lines · Austin S. Hemmelgarn
Quoted 7 lines · Jarkko Sakkinen
Quoted 6 lines · Pavel Machek
Quoted 5 lines · Jarkko Sakkinen

Intel(R) 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.

Quoted 9 lines
Quoted 6 lines
Quoted 4 lines

The firmware uses PRMRR registers to reserve an area of physical memory called Enclave Page Cache (EPC). There is a hardware unit in the processor called Memory Encryption Engine. The MEE encrypts and decrypts the EPC pages as they enter and leave the processor package.

What are non-evil use cases for this?

I'm not sure what you mean by non-evil.

Quoted 11 lines

I would think that this should be pretty straightforward. Pretty much every security technology integrated in every computer in existence has the potential to be used by malware for various purposes. Based on a cursory look at SGX, it is pretty easy to figure out how to use this to hide arbitrary code from virus scanners and the OS itself unless you have some way to force everything to be a debug enclave, which entirely defeats the stated purpose of the extensions. I can see this being useful for tight embedded systems. On a desktop which I have full control of physical access to though, it's something I'd immediately turn off, because the risk of misuse is so significant (I've done so on my new Thinkpad L560 too, although that's mostly because Linux doesn't support it yet).

Quoted 3 lines

The code in enclave binary is in clear text so it does not really allow you to completely hide any code. It's a signed binary, not encypted binary.

Quoted 8 lines

Umm. Now you are evil.

Yes, the code that starts in the enclave may not be encrypted, but I'm pretty sure the enclave will download some more code from remote server after attestation... x86 or some kind of interpretted code.

(But of course we already know that the technology is evil, as only Intel can use it, see Ingo's reply.)

Somehow that email from Ingo dissolved to my inbox :( Anyway, I gave now my response.

For my part I'll create a second revision of the patch set and update the documentation so that it has reasonable explanation about root of trust SGX.

Quoted 3 lines
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

/Jarkko

#20 lore raw

Re: [PATCH 5/6] intel_sgx: driver documentation

In reply to Andy Lutomirski
Quoted 102 lines · Andy Lutomirski
Quoted 15 lines · Jarkko Sakkinen
Quoted 14 lines · Andy Lutomirski

Documentation/x86/intel_sgx.txt line 86

Quoted 7 lines · Jarkko Sakkinen
Documentation/x86/intel_sgx.txt new file +6 -0
+SGX_IOCTL_ENCLAVE_INIT
+
+Initializes an enclave given by SIGSTRUCT and EINITTOKEN. Executes EINIT leaf
+instruction that will check that the measurement matches the one SIGSTRUCT and
+EINITTOKEN. EINITTOKEN is a data blob given by a special enclave called Launch
+Enclave and it is signed with a CPU's Launch Key.

Having thought about this for ten minutes, I have the following thought:

I think that we should seriously consider not allowing user code to supply EINITTOKEN at all. Here's why:

Quoted 6 lines
Quoted 3 lines

1. The nominal purpose of this thing is "launch control." I think that the decision of whether to launch an enclave belongs in the kernel to the extent that the kernel has the ability to control this.

I'm not sure why you would want to do this especially when you can use your own key pair for launch control in future.

Here are my thoughts. There are a few ways the system (firmware, MSR, and Intel policy) could be configured:

+++ status quo +++

Applications that ship enclaves come bundled with signatures and possibly certificate chains. They call into some SDK API to request launch permission. The SDK says "ok". Then the application asks the SDK to launch it. It's entirely unclear to me how Intel distributes the LE versions that make this work on Windows. I'm guessing they're bundled in the SDK, but for all I know, they're in the kernel.

I think that Linux should possibly refuse to support this mode upstream. If Linux were to support it, then it might actually match ISV-expected behavior better if the LE was bundled with the kernel -- after all, the ISV already has very little visibility into where the LE comes from, and it seems more like a system policy thing.

+++ current Skylakes with hypothetical Intel "launch anything" policy +++

If the combination of Intel policy and firmware configuration were to allow anything to launch, then the OS should either impose its own policy or allow anything to launch. I can easily imagine the implementation of this involving a channel by which the kernel proves to the LE that firmware/platform config is intended to allow "launch anything". In this case, I think this belongs either in the kernel or in a privileged daemon, and putting it in the kernel is probably much more straightforward. In any event, applications shouldn't need to worry about the nitty gritty details of where exactly their EINITTOKEN comes from.

+++ future chips with unlocked IA32_SGXLEPUBKEYHASH +++

The firmware policy really is "launch anything" in this case, and it's the kernel's job to restrict that further if it likes (by programming the MSRs and/or filtering EINIT). I think that the most natural way to implement this would be for the kernel to implement whatever policy it likes and to either ship an LE that accepts anything as part of the kernel image that's signed by a key where everyone knows the *private* key or to generate a random key pair at build time, build the enclave along with the kernel, and include the public key and the LE in the kernel image. In either case, I don't think that apps should need to ship this special LE -- the kernel should handle it.

If admins want to impose additional launch policy, then by all means Linux should offer that. I'm just not at all convinced that fiddling with the MSRs in new and complicated ways is the right way to do that -- I think the kernel should implement more advanced policy by filtering EINIT.

Keep in mind that, if the kernel is compromised, then the attacker can launch anything no matter what the kernel tries to do because the attacker controls the MSRs.

+++ future chips with IA32_SGXLEPUBKEYHASH set to a non-default value +++

I don't see a valid use case for this other than snake oil. One may well exist, but, if so, it hasn't been explained to me. If someone comes up with one, then, by all means, we could support it in the kernel. Nonetheless, an SGX-aware app that is designed to work under the status quo policy or in a "launch anything" regime should still work if the special local policy intends for it to work, and I don't think that app should need to possess a copy of the bespoke signed LE in order to function. IOW, to allow the same app to run here if policy is okay with it, I think we *have* to delegate EINITTOKEN generation to something other than the SGX-using app.

My intuition is that either the Windows approach to this is going to end up being a mess and very unpleasant for ISVs to work with or that Windows will move to a configuration in which EINITTOKEN generation is delegated to the kernel or to a privileged daemon that ships with the OS. I think that Linux should do that as well to avoid unpleasantness. If Linux ends up being easier to develop SGX applications on than Windows, then that's means that Linux did something right.

Quoted 8 lines

Also, in the unlocked-MSR case, I think that the kernel *must* implement EINIT filtering. The kernel should not allow an untrusted LE to run, because that LE might leak the raw EGETKEY output to a malicious party, and the implications of that might not be so nice. This is yet another argument in favor of having the kernel supply the LE so that the kernel can trust the LE. (Obviously, extracting raw *debug* EGETKEY output is possible even on Windows on current systems, but that raw output isn't particularly useful.)

MSR does not work when it is unlocked.

Quoted 8 lines
Quoted 3 lines

This would degrade the security of the SGX to the level of the running kernel binary.

How so? SGX is supposed to be secure even under the assumption that anyone can launch anything they want and even under the assumption that the kernel is malicious. If SGX fails at that, then it would be odd to blame kernel policy for that.

Maybe I understood this incorrectly somhow but IMHO launch control policy really should reside in an enclave because there it cannot be tampered by malicious code.

The code cannot be tampered at run-time but launch control policy could be if the LE is just in allow all mode.

Quoted 1 line

--Andy

/Jarkko

#55 lore raw
In reply to Dr. Greg Wettstein
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

/Jarkko

#56 lore raw
Quoted 10 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Which makes the feature pretty useless.

Quoted 11 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

We'll wait for that to happen.

Thanks,

tglx

#46 lore raw
In reply to Jarkko Sakkinen
Quoted 20 lines · Jarkko Sakkinen
Quoted 10 lines · Ingo Molnar
Quoted 6 lines · Andy Lutomirski
Quoted 1 line

What new syscalls would be needed for ssh to get all this support?

This patchset or similar, plus some user code and an enclave to use.

Sadly, on current CPUs, you also need Intel to bless the enclave. It looks like new CPUs might relax that requirement.

Quoted 8 lines

That looks like a fundamental technical limitation in my book - to an open source user this is essentially a very similar capability as tboot: it only allows the execution of externally blessed static binary blobs...

I don't think we can merge any of this upstream until it's clear that the hardware owner running open-source user-space can also freely define/start his own secure enclaves without having to sign the enclave with any external party. I.e. self-signed enclaves should be fundamentally supported as well.

Quoted 7 lines

Post Skylake we will have a set of MSRs for defining your own root of
trust: IA32_SGXLEPUBKEYHASH.

Andy had a concern that you could set root of trust multiple times, which could lead to potential attack scenarios. These MSRs are one-shot. ENCLS will fail if the launch control is locked. There's no possiblity to have a root of trust that is unlocked.

If this is actually true, can you ask the architecture folks to clarify their manual.

The MSR description in table 35-2 says "Write permitted if CPUID.(EAX=12H,ECX=0H): EAX[0]=1 && IA32_FEATURE_CONTROL[17] = 1 && IA32_FEATURE_CONTROL[0] = 1"

39.1.4 says "If IA32_FEATURE_CONTROL is locked with bit 17 set, IA32_SGXLEPUBKEYHASH MSRs are reconfigurable (writeable). If either IA32_FEATURE_CONTROL is not locked or
bit 17 is clear, the MSRs are read only. By leaving these MSRs writable, system SW or a VMM can support a plurality of Launch Enclaves for hosting multiple execution environments."

This does not sound like one-shot to me. It sounds quite clear, in fact, that it's *not* one-shot so a "plurality" of these things are supported.

--Andy

#21 lore raw

Re: [PATCH 5/6] intel_sgx: driver documentation

In reply to Jarkko Sakkinen
Quoted 103 lines · Jarkko Sakkinen
Quoted 102 lines · Andy Lutomirski
Quoted 15 lines · Jarkko Sakkinen
Quoted 14 lines · Andy Lutomirski

Documentation/x86/intel_sgx.txt line 86

Quoted 7 lines · Jarkko Sakkinen
Documentation/x86/intel_sgx.txt new file +6 -0
+SGX_IOCTL_ENCLAVE_INIT
+
+Initializes an enclave given by SIGSTRUCT and EINITTOKEN. Executes EINIT leaf
+instruction that will check that the measurement matches the one SIGSTRUCT and
+EINITTOKEN. EINITTOKEN is a data blob given by a special enclave called Launch
+Enclave and it is signed with a CPU's Launch Key.

Having thought about this for ten minutes, I have the following thought:

I think that we should seriously consider not allowing user code to supply EINITTOKEN at all. Here's why:

Quoted 6 lines
Quoted 3 lines

1. The nominal purpose of this thing is "launch control." I think that the decision of whether to launch an enclave belongs in the kernel to the extent that the kernel has the ability to control this.

I'm not sure why you would want to do this especially when you can use your own key pair for launch control in future.

Here are my thoughts. There are a few ways the system (firmware, MSR, and Intel policy) could be configured:

+++ status quo +++

Applications that ship enclaves come bundled with signatures and possibly certificate chains. They call into some SDK API to request launch permission. The SDK says "ok". Then the application asks the SDK to launch it. It's entirely unclear to me how Intel distributes the LE versions that make this work on Windows. I'm guessing they're bundled in the SDK, but for all I know, they're in the kernel.

I think that Linux should possibly refuse to support this mode upstream. If Linux were to support it, then it might actually match ISV-expected behavior better if the LE was bundled with the kernel -- after all, the ISV already has very little visibility into where the LE comes from, and it seems more like a system policy thing.

+++ current Skylakes with hypothetical Intel "launch anything" policy +++

If the combination of Intel policy and firmware configuration were to allow anything to launch, then the OS should either impose its own policy or allow anything to launch. I can easily imagine the implementation of this involving a channel by which the kernel proves to the LE that firmware/platform config is intended to allow "launch anything". In this case, I think this belongs either in the kernel or in a privileged daemon, and putting it in the kernel is probably much more straightforward. In any event, applications shouldn't need to worry about the nitty gritty details of where exactly their EINITTOKEN comes from.

+++ future chips with unlocked IA32_SGXLEPUBKEYHASH +++

The firmware policy really is "launch anything" in this case, and it's the kernel's job to restrict that further if it likes (by programming the MSRs and/or filtering EINIT). I think that the most natural way to implement this would be for the kernel to implement whatever policy it likes and to either ship an LE that accepts anything as part of the kernel image that's signed by a key where everyone knows the *private* key or to generate a random key pair at build time, build the enclave along with the kernel, and include the public key and the LE in the kernel image. In either case, I don't think that apps should need to ship this special LE -- the kernel should handle it.

If admins want to impose additional launch policy, then by all means Linux should offer that. I'm just not at all convinced that fiddling with the MSRs in new and complicated ways is the right way to do that -- I think the kernel should implement more advanced policy by filtering EINIT.

Keep in mind that, if the kernel is compromised, then the attacker can launch anything no matter what the kernel tries to do because the attacker controls the MSRs.

+++ future chips with IA32_SGXLEPUBKEYHASH set to a non-default value +++

I don't see a valid use case for this other than snake oil. One may well exist, but, if so, it hasn't been explained to me. If someone comes up with one, then, by all means, we could support it in the kernel. Nonetheless, an SGX-aware app that is designed to work under the status quo policy or in a "launch anything" regime should still work if the special local policy intends for it to work, and I don't think that app should need to possess a copy of the bespoke signed LE in order to function. IOW, to allow the same app to run here if policy is okay with it, I think we *have* to delegate EINITTOKEN generation to something other than the SGX-using app.

My intuition is that either the Windows approach to this is going to end up being a mess and very unpleasant for ISVs to work with or that Windows will move to a configuration in which EINITTOKEN generation is delegated to the kernel or to a privileged daemon that ships with the OS. I think that Linux should do that as well to avoid unpleasantness. If Linux ends up being easier to develop SGX applications on than Windows, then that's means that Linux did something right.

Quoted 11 lines
Quoted 8 lines

Also, in the unlocked-MSR case, I think that the kernel *must* implement EINIT filtering. The kernel should not allow an untrusted LE to run, because that LE might leak the raw EGETKEY output to a malicious party, and the implications of that might not be so nice. This is yet another argument in favor of having the kernel supply the LE so that the kernel can trust the LE. (Obviously, extracting raw *debug* EGETKEY output is possible even on Windows on current systems, but that raw output isn't particularly useful.)

MSR does not work when it is unlocked.

Are you *sure* about that?

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

This would degrade the security of the SGX to the level of the running kernel binary.

Quoted 8 lines
Quoted 4 lines

How so? SGX is supposed to be secure even under the assumption that anyone can launch anything they want and even under the assumption that the kernel is malicious. If SGX fails at that, then it would be odd to blame kernel policy for that.

Maybe I understood this incorrectly somhow but IMHO launch control policy really should reside in an enclave because there it cannot be tampered by malicious code.

I have heard one one explanation of why we would care if a compromised system were to allow an otherwise unauthorized enclave to launch: if that enclave contained encrypted malware. But there isn't any thing at all the kernel can do to prevent this. It's also very much unclear how this would be interesting from a malware standpoint, since the more "secure" (i.e. hard-to-reverse) malware scenarios all involve attestation as well, and the attestation system has its own set of security features.

--Andy

#63 lore raw
In reply to Jarkko Sakkinen

Hi, I hope the weekend is going well for everyone.

Quoted 11 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

As others have noted, unfortunately, this renders the technology largely useless on Linux, at least for anything beyond experimentation. That is somewhat strange given that one of the primary intentions of the technology is to push applications into untrusted cloud environments, particularly given the use of Linux in the 'cloud'. So I guess Azure is the only security beneficiary at this time... :-)

I assume that Intel will be releasing a launch enclave with its upcoming Linux SDK?

Quoted 11 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

It is encouraging to hear that Intel will be implementing one shot MSR's for the identity modulus signature. That would be consistent with what we would advocate for.

This now means the security of SGX on 'unlocked' platforms, at least from a trust perspective, will be dependent on using TXT so as to provide a hardware root of trust on which to base the SGX trust model. I was out walking with Izzy our Golden Retriever last night and as I thought about the implicatioins of all this I think the solution, at least as we would implement it, will tie together rather nicely.

I would assume that everyone is using signed Launch Control Policies (LCP) as we are. This means that TXT/tboot already has access to the public key which is used for the LCP data file signature. It would seem logical to have tboot compute the signature on that public key and program that signature into the module signature registers. That would tie the hardware root of trust to the SGX root of trust.

If that is undesirable the other alternative would be to pass a custom LCP policy element into tboot which would define the desired SGX trust signature.

It is unfortunate that SGX took the path it did on Linux. We actually have application for the technology now in our security supervisor.

When you say that unlocked SGX did not make it into Skylake does this mean we need to wait for a new micro-architecture or a die shrink? Given that tick/tock is now expanding in time it would be useful to have unlocked SGX be one of the extension features of Skylake. Otherwise there is certainly no rush for the Linux driver... :-)

Quoted 1 line

/Jarkko

Have a good week.

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: [email protected]
------------------------------------------------------------------------------
"If you get to thinkin' you're a person of some influence, try
orderin' somebody else's dog around."
-- Cowboy Wisdom

#64 lore raw
Quoted 5 lines · Dr. Greg Wettstein

This now means the security of SGX on 'unlocked' platforms, at least from a trust perspective, will be dependent on using TXT so as to provide a hardware root of trust on which to base the SGX trust model.

Can you explain what you mean by "trust"? In particular, what kind of "trust" would you have with a verified or trusted boot plus verified SGX launch root key that you would not have in the complete absence of hardware launch control.

I've heard multiple people say they want launch control but I've never heard a cogent explanation of a threat model in which it's useful.

Quoted 6 lines

I would assume that everyone is using signed Launch Control Policies (LCP) as we are. This means that TXT/tboot already has access to the public key which is used for the LCP data file signature. It would seem logical to have tboot compute the signature on that public key and program that signature into the module signature registers. That would tie the hardware root of trust to the SGX root of trust.

Now I'm confused. TXT, in theory*, lets you establish a good root of trust for TPM PCR measurements. So, with TXT, if you had one-shop launch control MSRs, you could attest that you've locked the launch control policy.

But what do you gain by doing such a thing? All you're actually attesting is that you locked it until the next reboot. Someone who subsequently compromises you can reboot you, bypass TXT on the next boot, and launch any enclave they want. In any event, SGX is supposed to make it so that your enclaves remain secure regardless of what happens to the kernel, so I'm at a loss for what you're trying to do.

* There are some serious concerns about the security of TXT. SGX is supposed to be better.

--Andy

#13 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jethro Beekman
Quoted 8 lines · Jethro Beekman
Quoted 6 lines · Jarkko Sakkinen
Quoted 3 lines
Quoted 1 line

Why would you want to do that?

...

Do you see this as a performance issue or why do you think that this would hurt that much?

Quoted 7 lines

I don't think it's a performance issue at all. I'm just giving an example of why you'd want to do this. I'm sure people who want to use this instruction set can come up with other uses, so I think the driver should support it. Other drivers on different platform might support this, in which case we should be compatible (to achieve the same enclave measurement). Other Linux drivers support it [1]. I would ask: why would you not want to do this? It seems trivial to expand the current flag into 16 separate flags; one for each 256-byte chunk in the page.

I'm fine with adding a 16-bit bitmask.

/Jarkko

#57 lore raw
In reply to Thomas Gleixner
Quoted 23 lines · Thomas Gleixner
Quoted 10 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Which makes the feature pretty useless.

Quoted 8 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

Quoted 5 lines
Quoted 3 lines

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

We'll wait for that to happen.

I fully understand if you (and others) want to keep this standpoint but what if we could get it to staging after I've revised it with suggested changes and internal changes in my TODO? Then it would not pollute the mainline kernel but still would be easily available for experimentation.

There was one header out of staging tree in the patch set sgx.h that I could place to the staging area in the next revision.

For the next revision I'll document how IA32_LEPUBKEYHASHx MSRs work based on some concerns that Andy raised so that we can hopefully have a better discussion about this feature.

Quoted 3 lines

Thanks,

tglx

/Jarkko

#58 lore raw
Quoted 24 lines · Jarkko Sakkinen
Quoted 23 lines · Thomas Gleixner
Quoted 10 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Which makes the feature pretty useless.

Quoted 8 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

We'll wait for that to happen.

I fully understand if you (and others) want to keep this standpoint but what if we could get it to staging after I've revised it with suggested

This should not go to staging at all. Either this is going to be a real useful driver or we just keep it out of tree.

Quoted 2 lines

changes and internal changes in my TODO? Then it would not pollute the mainline kernel but still would be easily available for experimentation.

How are we supposed to experiment with that if there is no launch enclave for Linux available?

Thanks,

tglx

maintainer
#61 lore raw
In reply to Jarkko Sakkinen
Quoted 28 lines · Jarkko Sakkinen
Quoted 27 lines · Thomas Gleixner
Quoted 10 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Which makes the feature pretty useless.

Quoted 11 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

Quoted 6 lines
Quoted 1 line

We'll wait for that to happen.

I fully understand if you (and others) want to keep this standpoint but what if we could get it to staging after I've revised it with suggested changes and internal changes in my TODO? Then it would not pollute the mainline kernel but still would be easily available for experimentation.

No, staging is not a "dumping ground", it's for code that is not ready to be merged, and has some work left to do on it and it shows forward progress on that goal. I don't put things in there that the maintainers of the subsystems it affects do not want merged. See the many previous examples of code that has been rejected for staging as examples of this.

sorry,

greg k-h

#14 lore raw

Re: [PATCH 3/6] intel_sgx: driver for Intel Secure Guard eXtensions

In reply to Jarkko Sakkinen
Quoted 17 lines · Jarkko Sakkinen
Quoted 8 lines · Jethro Beekman
Quoted 6 lines · Jarkko Sakkinen
Quoted 3 lines
Quoted 1 line

Why would you want to do that?

...

Do you see this as a performance issue or why do you think that this would hurt that much?

Quoted 7 lines

I don't think it's a performance issue at all. I'm just giving an example of why you'd want to do this. I'm sure people who want to use this instruction set can come up with other uses, so I think the driver should support it. Other drivers on different platform might support this, in which case we should be compatible (to achieve the same enclave measurement). Other Linux drivers support it [1]. I would ask: why would you not want to do this? It seems trivial to expand the current flag into 16 separate flags; one for each 256-byte chunk in the page.

Quoted 1 line

I'm fine with adding a 16-bit bitmask.

I did some experiementation and since this doesn't make the API more complicated it is probably ok.

Field that I declared was:

__u16 mrmask;

Measure one page:

  add_page.mrmask = ~0;

Skip the measurement:

add_page.mrmask = 0:

/Jarkko

#62 lore raw
In reply to Greg KH
Quoted 36 lines · Greg KH
Quoted 28 lines · Jarkko Sakkinen
Quoted 27 lines · Thomas Gleixner
Quoted 10 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Which makes the feature pretty useless.

Quoted 11 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

Quoted 6 lines
Quoted 1 line

We'll wait for that to happen.

I fully understand if you (and others) want to keep this standpoint but what if we could get it to staging after I've revised it with suggested changes and internal changes in my TODO? Then it would not pollute the mainline kernel but still would be easily available for experimentation.

Quoted 7 lines

No, staging is not a "dumping ground", it's for code that is not ready to be merged, and has some work left to do on it and it shows forward progress on that goal. I don't put things in there that the maintainers of the subsystems it affects do not want merged. See the many previous examples of code that has been rejected for staging as examples of this.

sorry,

NP, point taken.

Quoted 1 line

greg k-h

/Jarkko

#59 lore raw
In reply to Thomas Gleixner
Quoted 34 lines · Thomas Gleixner
Quoted 24 lines · Jarkko Sakkinen
Quoted 23 lines · Thomas Gleixner
Quoted 10 lines · Jarkko Sakkinen
Quoted 5 lines · Dr. Greg Wettstein

It would be helpful and instructive for anyone involved in this debate to review the following URL which details Intel's SGX licening program:

https://software.intel.com/en-us/articles/intel-sgx-product-licensing

I think it would be good to note that the licensing process is available only for Windows. For Linux you can only use debug enclaves at the moment. The default LE has "allow-all" policy for debug enclaves.

Which makes the feature pretty useless.

Quoted 8 lines
Quoted 7 lines

I think the only way forward to make all of this palatable is to embrace something similar to what has been done with Secure Boot. The Root Enclave Key will need to be something which can be reconfigured by the Platform Owner through BIOS/EFI. That model would take Intel off the hook from a security perspective and establish the notion of platform trust to be a bilateral relationship between a service provider and client.

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines

This concern has been raised many times now. Sadly this did not make into Skyle but in future we will have one shot MSRs (can be set only once per boot cycle) for defining your own root of trust.

We'll wait for that to happen.

I fully understand if you (and others) want to keep this standpoint but what if we could get it to staging after I've revised it with suggested

Quoted 8 lines

This should not go to staging at all. Either this is going to be a real useful driver or we just keep it out of tree.

Quoted 2 lines

changes and internal changes in my TODO? Then it would not pollute the mainline kernel but still would be easily available for experimentation.

How are we supposed to experiment with that if there is no launch enclave for Linux available?

Understood.

I appreciate all the feedback that I've received and come back later when the time is better with a refined patch set (especially Andys feedback showed that the documentation needs alot of rework).

Quoted 3 lines

Thanks,

tglx

/Jarkko

#60 lore raw
In reply to Thomas Gleixner

On Mon, May 09, 2016 at 08:27:04AM +0200, Thomas Gleixner wrote:

Good morning.

Quoted 4 lines
Quoted 4 lines · Jarkko Sakkinen

I fully understand if you (and others) want to keep this standpoint but what if we could get it to staging after I've revised it with suggested

Quoted 8 lines

This should not go to staging at all. Either this is going to be a real useful driver or we just keep it out of tree.

Quoted 3 lines

changes and internal changes in my TODO? Then it would not pollute the mainline kernel but still would be easily available for experimentation.

How are we supposed to experiment with that if there is no launch enclave for Linux available?

Build one in a simulator where an independent root enclave key can be established. At least thats the approach we are working on with Jarkko's patches.

Intel does have an instruction accurate simulator, Microsoft used it for the work which was reported in the Haven paper. I believe the Air Force academy used that simulator for their work on SGX as well.

As with other issues SGX related it is unclear why access to the simulator was/is restricted. Given that Gen6 hardware is now emerging there would seem to be even less reason to not have the simulator generically available to allow implementations to be tested.

Quoted 3 lines

Thanks,

tglx

Have a good day.

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: [email protected]
------------------------------------------------------------------------------
"Everything should be made as simple as possible, but not simpler."
-- Albert Einstein

#65 lore raw
In reply to Andy Lutomirski

On Sun, May 08, 2016 at 06:32:10PM -0700, Andy Lutomirski wrote:

Good morning, running behind on e-mail this week but wanted to get some reflections out on Andy's well taken comments and concerns.

Quoted 7 lines · Dr. Greg Wettstein
Quoted 5 lines

This now means the security of SGX on 'unlocked' platforms, at least from a trust perspective, will be dependent on using TXT so as to provide a hardware root of trust on which to base the SGX trust model.

Quoted 8 lines

Can you explain what you mean by "trust"? In particular, what kind of "trust" would you have with a verified or trusted boot plus verified SGX launch root key that you would not have in the complete absence of hardware launch control.

I've heard multiple people say they want launch control but I've never heard a cogent explanation of a threat model in which it's useful.

Trust means a lot of things and does not always have a 'threat model' associated with it. Security is all about the intersection of technology and economics and moving forward, will be driven by contractual obligations and re-insurance requirements, that is at least what we see happening and are involved with.

In a single root of trust, as was originally developed for SGX, trust consists of a bi-lateral contractual guarantee between Intel and a software developer. A contractual guarantee by Intel that an enclave launched under the security of its root key will have prescribed integrity and confidentiality guarantees. In reciprocation the developer delivers to Intel an implied trust that it will not use those guarantees to protect illicit or malicious software behavior.

That may not have implications with respect to a specific threat model but it could have significance in a re-insurance model where a client of the software environment can indicate that they had an expectation that code/data which was committed to this environment was appropriately protected. The refusal to launch, ie. a launch control policy, provides a hardware implementation of that trust guarantee.

All of this changes in a future which includes unlocked identity modulus signatures.

Quoted 11 lines
Quoted 6 lines

I would assume that everyone is using signed Launch Control Policies (LCP) as we are. This means that TXT/tboot already has access to the public key which is used for the LCP data file signature. It would seem logical to have tboot compute the signature on that public key and program that signature into the module signature registers. That would tie the hardware root of trust to the SGX root of trust.

Now I'm confused. TXT, in theory*, lets you establish a good root of trust for TPM PCR measurements. So, with TXT, if you had one-shop launch control MSRs, you could attest that you've locked the launch control policy.

Correct.

In the absence of launch control with an authoritative root of trust an alternative trust root has to be established. Integrating the load of the SGX identity signatures into tboot provides a framework where the trust guarantees discussed previously can be tied to the identity of the hardware platform and its provisioner.

This in turn provides a framework for contractual security guarantees between the platform provisioner and potential clients.

Quoted 7 lines

But what do you gain by doing such a thing? All you're actually attesting is that you locked it until the next reboot. Someone who subsequently compromises you can reboot you, bypass TXT on the next boot, and launch any enclave they want. In any event, SGX is supposed to make it so that your enclaves remain secure regardless of what happens to the kernel, so I'm at a loss for what you're trying to do.

As a Trusted Execution Environment (TEE) the notion of SGX is that it run run code and data in an Iago threat environment, where the hardware and operating system have been lost to an aggressor. You can technically provide that guarantee in the original SGX root of trust model but that changes in the presence of an unlocked identity model.

The TPM2 architecture will be the hardware security model moving forward. If you look at the new attestation model the hardware reference quote includes an irreversible clock field in order to defeat the threat model you describe above with a malware induced platform reboot.

Beyond that, at least in our work, we directly tie the launch of our security supervisor to an integrity chain which must be delivered from a functional TXT/TPM implementation. Our platform won't boot and deliver its qualifying attestation to a security counter-party if the TXT based boot was bypassed.

Given Microsoft's findings in their follow on paper to their Haven work a hardware/OS root of trust model is still important in a single root of trust model. At least until Intel comes up with a constant time hardware memory model, which is what we expect to see if Intel continues to move forward with refinenments to SGX and the notion of a commodity TEE.

Given the published vulnerabilities to memory side channel analysis the SGX platform currently requires that the hardware provisioner implement a guarantee that the platform is in a deterministic state and has not been influenced by interlopers. So platform behavior attestation is going to be an essential component moving forward, hence the need for involving TXT.

Quoted 2 lines

* There are some serious concerns about the security of TXT. SGX is supposed to be better.

SGX and TXT address different issues and, as noted above, will be synergistic with one another.

As somewhat of a nitpic, TXT is actually about a lot more then a root root of trust for the TPM2 PCR registers, since it addresses a lot of issues regarding the initialization of the chipset and processor to known states. Getting the PCR registers into a provable state is more or less a side effect of everything else it does.

The issue of the security of TXT comes up often and is secondary to the excellent work which Joanna Rutkowska and her colleagues did in defeating the early implementations of TXT. That work is five years old now and secondary to Intel reacting rather aggressively with modifications to their ACM, the technology hasn't seemed to be fruitful for security researchers since then.

One of the valid criticisms which Joanna leveled was over the lack of protection for SMI and the need for an STM monitor to protect the system in advance of tboot/TXT beginning its trust chain. Intel published the first revision of their documentation on their STM monitor in August 2015 so they have closed the loop on that aspect of her concerns. We will have to see how availability for that technology appears and how it stands up in practice.

Once again I leave the discussion with the fact that security is all about economics and risk management. Provable security is not going to exist in practice, particularly in an environment where aggressors have unfettered access to a hardware platform. Our experience suggests that there are economic opportunities and needs for making platforms which are 3-4 orders of magnitude more difficult to compromise.

Currently our industry revolves around hopelessly trying to patch software vulnerabilities, so we need to be open to trying different things and ideas.... :-)(

Quoted 1 line

--Andy

Have a good weekend.

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: [email protected]
------------------------------------------------------------------------------
"Man, despite his artistic pretensions, his sophistication and many
accomplishments, owes the fact of his existence to a six-inch layer of topsoil and the fact that it rains."
-- Anonymous writer on perspective.
GAUSSIAN quote.

#66 lore raw
Quoted 36 lines · Dr. Greg Wettstein

On Sun, May 08, 2016 at 06:32:10PM -0700, Andy Lutomirski wrote:

Good morning, running behind on e-mail this week but wanted to get some reflections out on Andy's well taken comments and concerns.

Quoted 7 lines · Dr. Greg Wettstein
Quoted 5 lines

This now means the security of SGX on 'unlocked' platforms, at least from a trust perspective, will be dependent on using TXT so as to provide a hardware root of trust on which to base the SGX trust model.

Quoted 8 lines

Can you explain what you mean by "trust"? In particular, what kind of "trust" would you have with a verified or trusted boot plus verified SGX launch root key that you would not have in the complete absence of hardware launch control.

I've heard multiple people say they want launch control but I've never heard a cogent explanation of a threat model in which it's useful.

Trust means a lot of things and does not always have a 'threat model' associated with it. Security is all about the intersection of technology and economics and moving forward, will be driven by contractual obligations and re-insurance requirements, that is at least what we see happening and are involved with.

In a single root of trust, as was originally developed for SGX, trust consists of a bi-lateral contractual guarantee between Intel and a software developer. A contractual guarantee by Intel that an enclave launched under the security of its root key will have prescribed integrity and confidentiality guarantees. In reciprocation the developer delivers to Intel an implied trust that it will not use those guarantees to protect illicit or malicious software behavior.

Quoted 7 lines

That may not have implications with respect to a specific threat model but it could have significance in a re-insurance model where a client of the software environment can indicate that they had an expectation that code/data which was committed to this environment was appropriately protected. The refusal to launch, ie. a launch control policy, provides a hardware implementation of that trust guarantee.

If so, this means that the client and/or their lawyers screwed up severely. The certification that integrity and confidentiality are protected has *nothing* to do with launch control. (It's trivial to break, too - just run the code in an SGX simulator or tweak the MACs and launch in debug mode. The code can't directly tell the difference.) In this regard, SGX is very much like TPM-based security. With a TPM, even if the hardware is somehow fully protected against physical attacks, the TPM will not prevent corrupted or malicious code from running. At best, it prevents such code from unsealing things protected by PCRs or from attesting to PCR state. Similarly, SGX won't prevent code from running on a corrupted platform (e.g. one that simulates SGX instructions). Instead, it prevents EREPORT and EGETKEY from deriving the expected keys in such an environment.

The correct way to do this is using the Quoting Enclave from Intel or using a differently bootstrapped approach -- see below. The verifier and Intel have an agreement and share some keys, and quoting actually checks something relevant.

Quoted 2 lines

All of this changes in a future which includes unlocked identity modulus signatures.

No, the only thing that changes is that the the ability for the lawyers or security architects to screw up in this particular way is reduced. EREPORT still checks signatures.

Quoted 15 lines
Quoted 8 lines
Quoted 7 lines

I would assume that everyone is using signed Launch Control Policies (LCP) as we are. This means that TXT/tboot already has access to the public key which is used for the LCP data file signature. It would seem logical to have tboot compute the signature on that public key and program that signature into the module signature registers. That would tie the hardware root of trust to the SGX root of trust.

Quoted 4 lines

Now I'm confused. TXT, in theory*, lets you establish a good root of trust for TPM PCR measurements. So, with TXT, if you had one-shop launch control MSRs, you could attest that you've locked the launch control policy.

Correct.

Quoted 8 lines

In the absence of launch control with an authoritative root of trust an alternative trust root has to be established. Integrating the load of the SGX identity signatures into tboot provides a framework where the trust guarantees discussed previously can be tied to the identity of the hardware platform and its provisioner.

This in turn provides a framework for contractual security guarantees between the platform provisioner and potential clients.

No, at most it provides a way for the platform provisioner and the client to mess up.

I can see two ways to get these types of assurances.

1. Use Intel's provisioning and quoting mechanism and sign Intel's quoting service contract.

2. Bootstrap your own. That is, when provisioning hardware, the platform provisioner stashes something derived from EGETKEY output in the provider's database. (This is more or less what Intel does when provisioning new Skylake chips, but nothing (except the current Launch Control mess) prevents another platform provisioner from doing the same thing when the buy the chip from Intel. Then use EREPORT to verify client enclaves to an enclave supplied by the provisioner and use EGETKEY in an enclave from the provisioner to allow that enclave to assert the client enclave's signer and the platform identity to the provisioner's cloud service, which can do whatever it likes with this assertion.

Launch Control doesn't help at all. In fact, it hurts, as the client would need to contract with their platform provisioner *and* with Intel if launch control is enabled.

Quoted 9 lines
Quoted 8 lines

But what do you gain by doing such a thing? All you're actually attesting is that you locked it until the next reboot. Someone who subsequently compromises you can reboot you, bypass TXT on the next boot, and launch any enclave they want. In any event, SGX is supposed to make it so that your enclaves remain secure regardless of what happens to the kernel, so I'm at a loss for what you're trying to do.

Quoted 6 lines

As a Trusted Execution Environment (TEE) the notion of SGX is that it run run code and data in an Iago threat environment, where the hardware and operating system have been lost to an aggressor. You can technically provide that guarantee in the original SGX root of trust model but that changes in the presence of an unlocked identity model.

I think you're still confusing launch control with attestation. They're so different that Intel's policy pages about them don't even appear to reference each other.

Quoted 11 lines

The TPM2 architecture will be the hardware security model moving forward. If you look at the new attestation model the hardware reference quote includes an irreversible clock field in order to defeat the threat model you describe above with a malware induced platform reboot.

Beyond that, at least in our work, we directly tie the launch of our security supervisor to an integrity chain which must be delivered from a functional TXT/TPM implementation. Our platform won't boot and deliver its qualifying attestation to a security counter-party if the TXT based boot was bypassed.

Emphasis missing on "deliver its qualifying attestation to a security counter-party".

The really annoying thing about TPM and TEE-style security is that you have to root your trust in boot-time configuration. SGX is supposed to get us away from that. By trying to assert things about MSRs, you're forcing yourself to get stuck with boot-time configuration checks, and you're losing the advantage of SGX. You might as well rely solely on the TPM if you want to do this.

Quoted 8 lines

Given Microsoft's findings in their follow on paper to their Haven work a hardware/OS root of trust model is still important in a single root of trust model. At least until Intel comes up with a constant time hardware memory model, which is what we expect to see if Intel continues to move forward with refinenments to SGX and the notion of a commodity TEE.

Quoted 6 lines

Given the published vulnerabilities to memory side channel analysis the SGX platform currently requires that the hardware provisioner implement a guarantee that the platform is in a deterministic state and has not been influenced by interlopers. So platform behavior attestation is going to be an essential component moving forward, hence the need for involving TXT.

AFAICT Intel does this already. SGX won't launch enclaves at all unless some ACM certifies that the MEE is set up right.

<off-topic>

Quoted 4 lines
Quoted 3 lines

* There are some serious concerns about the security of TXT. SGX is supposed to be better.

Quoted 8 lines

SGX and TXT address different issues and, as noted above, will be synergistic with one another.

As somewhat of a nitpic, TXT is actually about a lot more then a root root of trust for the TPM2 PCR registers, since it addresses a lot of issues regarding the initialization of the chipset and processor to known states. Getting the PCR registers into a provable state is more or less a side effect of everything else it does.

I think you're thinking about this wrong. TXT is about doing various things to securely set up the platform and then, critically, certifying that it did those things by setting up the PCRs. Just like SGX is about launching an enclave securely and then certifying it with EGETKEY and EREPORT. If all you do is boot your kernel with TXT + tboot and ignore the PCRs, you gain nothing at all except for some cold-boot protection.

Quoted 8 lines

The issue of the security of TXT comes up often and is secondary to the excellent work which Joanna Rutkowska and her colleagues did in defeating the early implementations of TXT. That work is five years old now and secondary to Intel reacting rather aggressively with modifications to their ACM, the technology hasn't seemed to be fruitful for security researchers since then.

Quoted 7 lines

One of the valid criticisms which Joanna leveled was over the lack of protection for SMI and the need for an STM monitor to protect the system in advance of tboot/TXT beginning its trust chain. Intel published the first revision of their documentation on their STM monitor in August 2015 so they have closed the loop on that aspect of her concerns. We will have to see how availability for that technology appears and how it stands up in practice.

Availability appears to be nil. Also, AFAIK there's no point unless you can audit the monitor, which is more or less the same as auditing the SMRAM code.

Also, have you noticed that the TPM2 appears to be a *software* thing, running in the same privilege domain as the Intel AMT *web server*? Maybe Intel finally ditched that -- I haven't checked.

</off-topic>

--Andy

#29 lore raw

Re: [PATCH 6/6] intel_sgx: TODO file for the staging area

In reply to Jethro Beekman
Quoted 5 lines · Jethro Beekman
Quoted 2 lines · Jarkko Sakkinen

In order to write test code I would need to use the SDK at minimum to generate EINITTOKEN for the test enclave.

You could do this right now with the Rust tools for SGX [1]

Right, you are converting Windows LE to work with Linux, cool :)

I'm planning to set up a project site to 01.org as soon as I have time with link to my Linux tree. You probably don't mind if I also link these tools there? I'm soon ready with all of the suggestions for the API that you proposed and want to use your tools to test them in additional to some internal tests that I have.

Thank you for doing this effort.

/Jarkko