mirror of
https://github.com/clearlinux/graphene.git
synced 2026-09-06 22:01:29 +00:00
Introduce one, central manifest, zero-config children and constant MRENCLAVE
This is the next part of the great loader rework, with a lot of breaking changes: - Complete removal of the "trusted children" thing - now children processes can be spawned arbitrarily and from arbitrary mountpoint types, without any additional configuration needed. - There's a new, required option in the manifest: `libos.entrypoint` - it specifies the URI to the entry binary in the first process. There's no need anymore to name the manifest and the first binary identically. - On SGX, the main binary is not measured in MRENCLAVE anymore - only PAL, LibOS and the manifest are measured. This is enough to bind MRENCLAVE to a specific entrypoint user executable if wanted - it just has to be mounted as a trusted file. - All Graphene SGX enclaves have now exactly the same MRENCLAVE. This is a hash of a "Graphene stub", which can "fork" into one of two states in runtime: initial process or child. The initial process creates a new "Graphene namespace" with a clean state, it can also be attested remotely (contrary to child processes). The initial process can spawn children processes by spawning a Graphene stub and directing it to start in the child mode. It then attests it locally, and if successful, establishes an encrypted pipe, "connects" to its own namespace and treats as trusted (including sending protected files key). - Now, there's only one, central manifest describing the initial state of a Graphene instance which can be spawned from it (previously, each process required a separate manifest which could have different configuration - which wasn't actually supported and didn't make sense design-wise). One downside of central manifests is that all processes require the same enclave configuration (e.g. size), but that was already the case so far because of broken checkpointing code. Also, this is only a temporary problem, which will cease to exist after the introduction of EDMM. - `sgx.static_address` was renamed to `sgx.nonpie_binary` and now has to be inserted manually by users (`sgx_sign` tools doesn't know about the binaries run inside, which can be even provided or generated in runtime by the user's workload). - Caveat: the memory gap for non-PIE executables was removed because it requires adding a new option to the manifest to be cleanly implemented. This is left for some future loader rework PR.
This commit is contained in:
@@ -1,2 +1 @@
|
||||
/nodejs
|
||||
/OUTPUT
|
||||
|
||||
+17
-38
@@ -8,7 +8,7 @@
|
||||
# Use `make clean` to remove Graphene-generated files.
|
||||
|
||||
THIS_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
|
||||
NODEJS_DIR ?= /usr/bin/
|
||||
NODEJS_DIR ?= /usr/bin
|
||||
|
||||
# Relative path to Graphene root and key for enclave signing
|
||||
GRAPHENEDIR ?= ../..
|
||||
@@ -21,49 +21,31 @@ GRAPHENEDEBUG = none
|
||||
endif
|
||||
|
||||
.PHONY: all
|
||||
all: nodejs.manifest | nodejs pal_loader
|
||||
all: nodejs.manifest | pal_loader
|
||||
ifeq ($(SGX),1)
|
||||
all: nodejs.token
|
||||
all: nodejs.manifest.sgx nodejs.sig nodejs.token
|
||||
endif
|
||||
|
||||
include ../../Scripts/Makefile.configs
|
||||
|
||||
# Node.js dependencies (generated from ldd). For SGX, the manifest needs to list all the libraries
|
||||
# loaded during execution, so that the signer can include the file hashes.
|
||||
# Generate manifest rules for Node.js dependencies.
|
||||
# We'll duplicate some Glibc libraries (which Graphene provides in a customized version), but
|
||||
# there's no harm in this.
|
||||
.INTERMEDIATE: trusted-libs
|
||||
trusted-libs: ../common_tools/get_deps.sh
|
||||
../common_tools/get_deps.sh $(NODEJS_DIR)/nodejs > $@
|
||||
|
||||
# We need to replace Glibc dependencies with Graphene-specific Glibc. The Glibc binaries are
|
||||
# already listed in the manifest template, so we can skip them from the ldd results.
|
||||
GLIBC_DEPS = linux-vdso.so.1 /lib64/ld-linux-x86-64.so.2 libc.so.6 libm.so.6 librt.so.1 \
|
||||
libdl.so.2 libpthread.so.0 libutil.so.1 libresolv.so.2 libnss_dns.so.2
|
||||
|
||||
# List all the Node.js dependencies, besides Glibc libraries
|
||||
.INTERMEDIATE: nodejs-deps
|
||||
nodejs-deps:
|
||||
@ldd $(NODEJS_DIR)nodejs | \
|
||||
awk '{if ($$2 =="=>") {print $$1}}' | \
|
||||
sort | uniq | grep -v -x $(patsubst %,-e %,$(GLIBC_DEPS)) > $@
|
||||
|
||||
# Generate manifest rules for Node.js dependencies
|
||||
.INTERMEDIATE: nodejs-trusted-libs
|
||||
nodejs-trusted-libs: nodejs-deps
|
||||
@for F in `cat nodejs-deps`; do \
|
||||
P=`ldd $(NODEJS_DIR)nodejs | grep $$F | awk '{print $$3; exit}'`; \
|
||||
N=`echo $$F | tr --delete '.' | tr --delete '-' | tr --delete '+'`; \
|
||||
echo -n "sgx.trusted_files.$$N = \\\"file:$$P\\\"\\\\n"; \
|
||||
done > $@
|
||||
|
||||
nodejs.manifest: nodejs.manifest.template nodejs-trusted-libs
|
||||
@sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \
|
||||
-e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \
|
||||
-e 's|$$(NODEJS_DIR)|'"$(NODEJS_DIR)"'|g' \
|
||||
-e 's|$$(NODEJS_TRUSTED_LIBS)|'"`cat nodejs-trusted-libs`"'|g' \
|
||||
-e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \
|
||||
$< > $@
|
||||
nodejs.manifest: nodejs.manifest.template trusted-libs
|
||||
(sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \
|
||||
-e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \
|
||||
-e 's|$$(NODEJS_DIR)|'"$(NODEJS_DIR)"'|g' \
|
||||
-e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \
|
||||
$<; \
|
||||
cat trusted-libs) > $@
|
||||
|
||||
# Generate SGX-specific manifest, enclave signature, and token for enclave initialization
|
||||
nodejs.manifest.sgx: nodejs.manifest helloworld.js
|
||||
$(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \
|
||||
-exec nodejs \
|
||||
-libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \
|
||||
-key $(SGX_SIGNER_KEY) \
|
||||
-manifest $< -output $@
|
||||
@@ -73,9 +55,6 @@ nodejs.sig: nodejs.manifest.sgx
|
||||
nodejs.token: nodejs.sig
|
||||
$(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $<
|
||||
|
||||
nodejs:
|
||||
ln -s $(NODEJS_DIR)nodejs $@
|
||||
|
||||
pal_loader:
|
||||
ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@
|
||||
|
||||
@@ -87,7 +66,7 @@ check: all
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(RM) *.manifest *.manifest.sgx *.token *.sig nodejs pal_loader OUTPUT
|
||||
$(RM) *.manifest *.manifest.sgx *.token *.sig pal_loader OUTPUT
|
||||
|
||||
.PHONY: distclean
|
||||
distclean: clean
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# This manifest was prepared and tested on Ubuntu 18.04.
|
||||
|
||||
loader.argv0_override = "nodejs"
|
||||
libos.entrypoint = "file:$(NODEJS_DIR)/nodejs"
|
||||
|
||||
# LibOS layer library of Graphene. There is currently only one implementation,
|
||||
# so it is always set to libsysdb.so.
|
||||
@@ -43,8 +43,9 @@ sgx.enclave_size = "2G"
|
||||
# enclave creation time.
|
||||
sgx.thread_num = 8
|
||||
|
||||
# Specify all libraries used by Node.js and its dependencies (including all libs
|
||||
# Specify all files used by Node.js and its dependencies (including all libs
|
||||
# which can be loaded at runtime via dlopen).
|
||||
sgx.trusted_files.nodejs = "file:$(NODEJS_DIR)/nodejs"
|
||||
sgx.trusted_files.ld = "file:$(GRAPHENEDIR)/Runtime/ld-linux-x86-64.so.2"
|
||||
sgx.trusted_files.libc = "file:$(GRAPHENEDIR)/Runtime/libc.so.6"
|
||||
sgx.trusted_files.libm = "file:$(GRAPHENEDIR)/Runtime/libm.so.6"
|
||||
@@ -52,7 +53,8 @@ sgx.trusted_files.libdl = "file:$(GRAPHENEDIR)/Runtime/libdl.so.2"
|
||||
sgx.trusted_files.librt = "file:$(GRAPHENEDIR)/Runtime/librt.so.1"
|
||||
sgx.trusted_files.libutil = "file:$(GRAPHENEDIR)/Runtime/libutil.so.1"
|
||||
sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0"
|
||||
$(NODEJS_TRUSTED_LIBS)
|
||||
sgx.trusted_files.libstdcpp = "file:$(GRAPHENEDIR)/Runtime/libstdc++.so.6"
|
||||
sgx.trusted_files.libgcc_s = "file:$(GRAPHENEDIR)/Runtime/libgcc_s.so.1"
|
||||
|
||||
# JavaScript (trusted)
|
||||
# input file
|
||||
sgx.trusted_files.javascript = "file:helloworld.js"
|
||||
|
||||
Reference in New Issue
Block a user