diff --git a/.ci/lib/stage-clean-check.jenkinsfile b/.ci/lib/stage-clean-check.jenkinsfile index a4366d27..b4aeb194 100644 --- a/.ci/lib/stage-clean-check.jenkinsfile +++ b/.ci/lib/stage-clean-check.jenkinsfile @@ -17,14 +17,14 @@ stage('clean-check') { make -C Examples/python-scipy-insecure clean make -C Examples/bash clean make -C Examples/curl clean - #make -C Examples/gcc distclean + make -C Examples/gcc distclean make -C Examples/memcached distclean make -C Examples/redis distclean make -C Examples/lighttpd distclean make -C Examples/nginx distclean make -C Examples/apache distclean make -C Examples/blender distclean - #make -C Examples/r distclean + make -C Examples/r distclean make -C Pal/src PAL_HOST=Skeleton clean make -C Examples/ra-tls-mbedtls distclean diff --git a/.ci/lib/stage-test-direct.jenkinsfile b/.ci/lib/stage-test-direct.jenkinsfile index 1e475894..a94566e7 100644 --- a/.ci/lib/stage-test-direct.jenkinsfile +++ b/.ci/lib/stage-test-direct.jenkinsfile @@ -37,7 +37,6 @@ stage('test-direct') { make check ''' } - /* Disabled until we fix Graphene loader timeout(time: 5, unit: 'MINUTES') { sh ''' cd Examples/gcc @@ -45,7 +44,6 @@ stage('test-direct') { make check ''' } - */ timeout(time: 10, unit: 'MINUTES') { sh ''' cd Examples/memcached @@ -78,7 +76,7 @@ stage('test-direct') { make -j8 all make start-graphene-server & sleep 1 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh 127.0.0.1:8003 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh 127.0.0.1:8003 ''' } timeout(time: 10, unit: 'MINUTES') { @@ -87,7 +85,7 @@ stage('test-direct') { make -j8 all make start-graphene-server & sleep 1 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh 127.0.0.1:8002 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh 127.0.0.1:8002 ''' } timeout(time: 20, unit: 'MINUTES') { @@ -96,8 +94,8 @@ stage('test-direct') { make -j8 all make start-graphene-server & sleep 1 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh 127.0.0.1:8001 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh https://127.0.0.1:8443 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh 127.0.0.1:8001 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh https://127.0.0.1:8443 ''' } timeout(time: 5, unit: 'MINUTES') { @@ -107,7 +105,6 @@ stage('test-direct') { make check ''' } - /* Disabled until we fix Graphene loader (uses execve('/bin/sh')) timeout(time: 5, unit: 'MINUTES') { sh ''' cd Examples/r @@ -115,5 +112,4 @@ stage('test-direct') { make check ''' } - */ } diff --git a/.ci/lib/stage-test-sgx.jenkinsfile b/.ci/lib/stage-test-sgx.jenkinsfile index b67ff236..ff2170cd 100644 --- a/.ci/lib/stage-test-sgx.jenkinsfile +++ b/.ci/lib/stage-test-sgx.jenkinsfile @@ -27,7 +27,6 @@ stage('test-sgx') { make ${MAKEOPTS} check ''' } - /* Disabled until we fix Graphene loader timeout(time: 10, unit: 'MINUTES') { sh ''' cd Examples/gcc @@ -35,7 +34,6 @@ stage('test-sgx') { make ${MAKEOPTS} check ''' } - */ timeout(time: 15, unit: 'MINUTES') { sh ''' cd Examples/memcached @@ -71,7 +69,7 @@ stage('test-sgx') { make ${MAKEOPTS} make ${MAKEOPTS} start-graphene-server & sleep 10 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh 127.0.0.1:8003 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh 127.0.0.1:8003 ''' } timeout(time: 15, unit: 'MINUTES') { @@ -80,7 +78,7 @@ stage('test-sgx') { make ${MAKEOPTS} make ${MAKEOPTS} start-graphene-server & sleep 30 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh 127.0.0.1:8002 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh 127.0.0.1:8002 ''' } timeout(time: 25, unit: 'MINUTES') { @@ -89,8 +87,8 @@ stage('test-sgx') { make ${MAKEOPTS} make ${MAKEOPTS} start-graphene-server & sleep 30 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh 127.0.0.1:8001 - LOOP=1 CONCURRENCY_LIST="1 32" ./benchmark-http.sh https://127.0.0.1:8443 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh 127.0.0.1:8001 + LOOP=1 CONCURRENCY_LIST="1 32" ../common_tools/benchmark-http.sh https://127.0.0.1:8443 ''' } timeout(time: 5, unit: 'MINUTES') { @@ -100,7 +98,6 @@ stage('test-sgx') { make ${MAKEOPTS} check ''' } - /* Disabled until we fix Graphene loader (uses execve('/bin/sh')) timeout(time: 5, unit: 'MINUTES') { sh ''' cd Examples/r @@ -108,7 +105,6 @@ stage('test-sgx') { make ${MAKEOPTS} check ''' } - */ timeout(time: 5, unit: 'MINUTES') { sh ''' # test SGX remote attestation only on Ubuntu 18.04 to keep internet requests to minimum diff --git a/Documentation/devel/debugging.rst b/Documentation/devel/debugging.rst index 1b5847b2..5c649b50 100644 --- a/Documentation/devel/debugging.rst +++ b/Documentation/devel/debugging.rst @@ -19,7 +19,7 @@ To build Graphene with debug symbols, the source code needs to be compiled with To run Graphene with GDB, use the following command to run your application:: - GDB=1 [Graphene Directory]/Runtime/pal_loader [executable] [arguments] + GDB=1 [Graphene Directory]/Runtime/pal_loader [application] [arguments] Debugging with SGX support -------------------------- @@ -46,4 +46,4 @@ run the following commands:: To run Graphene with GDB, use the Graphene loader (``pal_loader``) and specify ``GDB=1``:: - GDB=1 SGX=1 [Graphene Directory]/Runtime/pal_loader [executable] [arguments] + GDB=1 SGX=1 [Graphene Directory]/Runtime/pal_loader [application] [arguments] diff --git a/Documentation/devel/performance.rst b/Documentation/devel/performance.rst index c2d1afd3..985991b5 100644 --- a/Documentation/devel/performance.rst +++ b/Documentation/devel/performance.rst @@ -316,10 +316,10 @@ overheads. To summarize, there are two sources of overhead for multi-process applications in Graphene: -#. ``Fork()``, ``vfork()``, ``clone()`` as well as the ``execve()`` system calls - are very expensive in Graphene and in SGX in general. This is because Intel - SGX lacks the mechanisms for memory sharing and copy-on-write semantics. They - are emulated via checkpoint-and-restore in Graphene. +#. ``Fork()``, ``vfork()`` and ``clone()`` system calls are very expensive in + Graphene and in SGX in general. This is because Intel SGX lacks the + mechanisms for memory sharing and copy-on-write semantics. They are emulated + via checkpoint-and-restore in Graphene. #. Inter-Process Communication (IPC) is moderately expensive in Graphene because all IPC is transparently encrypted/decrypted using the TLS-PSK with AES-GCM @@ -391,9 +391,9 @@ encrypts many means of communication: #. Files marked as ``sgx.protected_files`` are transparently encrypted/decrypted on each file access via SGX SDK Merkle-tree format. -#. ``Fork/vfork/clone/execve`` all require to generate an encrypted checkpoint - of the whole enclave memory, send it from parent process to the child, and - decrypt it (all via TLS-PSK). +#. ``Fork/vfork/clone`` all require to generate an encrypted checkpoint of the + whole enclave memory, send it from parent process to the child, and decrypt + it (all via TLS-PSK). #. All SGX attestation, RA-TLS, and Secret Provisioning network communication is encrypted via TLS. Moreover, attestation depends on the internet speed and @@ -472,7 +472,7 @@ Recording samples with ``perf record`` To record (saves ``perf.data``):: - perf record ./pal_loader executable + perf record ./pal_loader application To view the report for ``perf.data``:: diff --git a/Documentation/manifest-syntax.rst b/Documentation/manifest-syntax.rst index 5c8c1033..39d77864 100644 --- a/Documentation/manifest-syntax.rst +++ b/Documentation/manifest-syntax.rst @@ -50,6 +50,16 @@ This syntax specifies the libraries to be preloaded before loading the executable. The URIs of the libraries must be separated by commas. The libraries must be ELF binaries. This usually contains the LibOS library ``libsysdb.so``. +Entrypoint +^^^^^^^^^^ + +:: + + libos.entrypoint = "URI" + +This specifies the first executable which is to be started when spawning a +Graphene instance from this manifest file. + Command-line arguments ^^^^^^^^^^^^^^^^^^^^^^ @@ -260,6 +270,17 @@ The PAL and library OS code/data count towards this size value, as well as the application memory itself: application's code, stack, heap, loaded application libraries, etc. The application cannot allocate memory that exceeds this limit. +Non-PIE binaries +^^^^^^^^^^^^^^^^ + +:: + + sgx.nonpie_binary = [1|0] + (Default: 0) + +This setting tells Graphene whether to use a specially crafted memory layout, +which is required to support non-relocatable binaries (non-PIE). + Number of threads ^^^^^^^^^^^^^^^^^ @@ -400,19 +421,6 @@ trusted and allowed are allowed for access, and Graphene-SGX emits a warning message for every such file. This is a convenient way to determine the set of files that the ported application uses. -Trusted child processes -^^^^^^^^^^^^^^^^^^^^^^^ - -:: - - sgx.trusted_children.[identifier] = "[URI of signature file (.sig)]" - -This syntax specifies the signatures of allowed child processes of the current -application. Upon process creation, the enclave in the current (parent) process -will attest the enclave in the child process, by comparing to the signatures of -the trusted children. If the child process is not trusted, the enclave will -refuse to communicate with it. - Attestation and quotes ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Documentation/manpages/gsc.rst b/Documentation/manpages/gsc.rst index fa23cdc2..52c7e5be 100644 --- a/Documentation/manpages/gsc.rst +++ b/Documentation/manpages/gsc.rst @@ -52,8 +52,8 @@ addition, install the Docker client python package via pip. GSC requires Python Kernel modules and services --------------------------- -To run Intel SGX applications, please install the following kernel driver and -services. +To run with Intel SGX, please install the following kernel driver and +services: - `Intel SGX driver `__ - `Intel SGX SDK `__ @@ -130,21 +130,15 @@ Synopsis: .. option:: -c - Specify configuration file. Default: :file:`config.yaml` + Specify configuration file. Default: :file:`config.yaml`. .. option:: IMAGE-NAME - Name of the application Docker image + Name of the application Docker image. -.. option:: APP1.MANIFEST - - Application-specific manifest file for the executable entrypoint of the - Docker image - -.. option:: APPN.MANIFEST - - Application-specific Manifest for the n-th application +.. option:: APP.MANIFEST + Manifest file (Graphene configuration). .. program:: gsc-sign-image @@ -227,8 +221,8 @@ Synopsis: Using Graphene's trusted command line arguments ----------------------------------------------- -Most applications aren't designed to run with attacker-controlled arguments. -Allowing an attacker to control application arguments can break the security of +Most executables aren't designed to run with attacker-controlled arguments. +Allowing an attacker to control executable arguments can break the security of the resulting enclave. :command:`gsc build` uses the existing Docker image's entrypoint and cmd fields @@ -240,43 +234,15 @@ specified during :command:`docker run` are ignored. To be able to provide arguments at runtime, the image build has to enable this via the option :option:`--insecure-args `. -Application-specific manifest files ------------------------------------ - -Each application loaded by Graphene requires a separate manifest file. -:program:`gsc` semi-automatically generates these manifest files. It generates a -list of trusted files, assumes values for the number of stacks and memory size, -and generates the chain of trusted children (see below for details). To allow -specializing each application manifest, :program:`gsc` allows the user to -augment each generated manifest. In particular, this allows to add additional -trusted or allowed files and specify a particular enclave size or number of -Thread Control Structures (TCS). - -:program:`gsc` allows application-specific manifest files to be empty or not to -exist. In this case :program:`gsc` generates a generic manifest file. - Docker images starting multiple applications -------------------------------------------- Depending on the use case, a Docker container may execute multiple applications. -The Docker image defines the entrypoint application which could fork additional -applications. A common pattern in Docker images executes an entrypoint script -which calls a set of applications. In Graphene the manifest of a parent -application has to specify all trusted children that might be forked. - -We define the parent-child relationship by overestimating the set of possible -children. Multiple applications are specified as arguments to :program:`gsc`. -The example below creates a Docker image with three applications. Based on the -specified chain of applications, :program:`gsc` generates parent-child -relationships between application ``appi`` and all applications after it in -the chain (``> appi``). This overestimates the set of trusted children and may -not map to the actual partent-child relationship. In the example below ``app1`` -may call ``app2`` or ``app3``, and ``app2`` may call ``app3``, but ``app2`` may -*not* call ``app1``, and ``app3`` may *not* call ``app1`` or ``app2``. - -.. code-block:: sh - - gsc build image app1.manifest app2.manifest app3.manifest +The Docker image defines the entrypoint executable which could fork additional +executables. A common pattern in Docker images is executing an entrypoint script +which calls a set of executables. Similarly to Docker, Graphene has a +corresponding option (``libos.entrypoint``) which should point to the first +executable started inside Graphene namespace. Stages of building graphenized SGX Docker images ------------------------------------------------ @@ -375,7 +341,7 @@ Run graphenized Docker images Execute :command:`docker run` command via Docker CLI and provide gsgx and isgx/sgx device, and the PSW/AESM socket. Additional Docker options and -application arguments may be supplied to the :command:`docker run` command. +executable arguments may be supplied to the :command:`docker run` command. .. warning:: Forwarding devices to a container lowers security of the host. GSC should @@ -399,8 +365,8 @@ application arguments may be supplied to the :command:`docker run` command. .. option:: ARGUMENTS - Application arguments to be supplied to the application launching inside the - Docker container and Graphene. Such arguments may only be provided when + Arguments to be supplied to the executable launching inside the Docker + container and Graphene. Such arguments may only be provided when :option:`--insecure-args ` was specified during :command:`gsc build`. @@ -513,10 +479,10 @@ Workaround Allowing dynamic file contents via Graphene protected files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - Docker volumes can include Graphene protected files. As a result Graphene - can open these protected files without knowing the exact contents as long as - the protected file was configured in the application-specific manifest. The - complete and secure use of protected files may require additional steps. + Docker volumes can include Graphene protected files. As a result Graphene can + open these protected files without knowing the exact contents as long as the + protected file was configured in the manifest. The complete and secure use of + protected files may require additional steps. Integration of Docker Secrets ----------------------------- @@ -524,7 +490,7 @@ Integration of Docker Secrets Docker Secrets are automatically pulled by Docker and the results are stored either in environment variables or mounted as files. GSC is currently unaware of such files and hence, cannot mark them trusted. Similar to trusted data, these -files may be added to the application-specific manifest. +files may be added to the manifest. Access to files in excluded paths --------------------------------- @@ -533,7 +499,7 @@ The manifest generation excludes all files and paths starting with :file:`/boot`, :file:`/dev`, :file:`/proc`, :file:`/var`, :file:`/sys`, and :file:`/etc/rc` from the list of trusted files. If your application relies on some files in these directories, you must manually add them to the -application-specific manifest:: +manifest:: sgx.trusted_files.[identifier] = "[URI]" or diff --git a/Documentation/manpages/pal_loader.rst b/Documentation/manpages/pal_loader.rst index fc553ba0..5ea7dcd2 100644 --- a/Documentation/manpages/pal_loader.rst +++ b/Documentation/manpages/pal_loader.rst @@ -11,7 +11,7 @@ Synopsis ======== -:command:`pal_loader` [SGX] [GDB] {<*EXECUTABLE*>} [<*ARGS*> ...] +:command:`pal_loader` [SGX] [GDB] {<*APPLICATION*>} [<*ARGS*> ...] Description =========== diff --git a/Documentation/pal/host-abi.rst b/Documentation/pal/host-abi.rst index 5c7b8074..313e3a06 100644 --- a/Documentation/pal/host-abi.rst +++ b/Documentation/pal/host-abi.rst @@ -28,18 +28,9 @@ is described in :doc:`../manifest-syntax`. Manifest and executable loading ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -To run a program in Graphene properly, the PAL loader generally requires both a -manifest and an executable. The user shall specify the executable to load in -the command line, and the PAL loader will try to locate the manifest based on -the file name. - -Precisely, the loading rules for the manifest and executable are as follows: - -#. The first argument given to :program:`pal_loader` has to be an executable. -#. The loader will search for the - manifest in the following order: the same file name as the executable with - a ``.manifest`` or ``.manifest.sgx`` extension, or ``manifest`` file - without any extension. +To run a program in Graphene the PAL loader needs a manifest, which will +describe the whole environment inside Graphene namespace. It also describes +which executable to start first (via ``libos.entrypoint``). Data types and variables ------------------------ diff --git a/Documentation/tutorials/pytorch/index.rst b/Documentation/tutorials/pytorch/index.rst index a6682e64..41c33377 100644 --- a/Documentation/tutorials/pytorch/index.rst +++ b/Documentation/tutorials/pytorch/index.rst @@ -180,7 +180,7 @@ Navigate to the PyTorch example directory we examined in the previous section:: cd /Examples/pytorch -Let's take a look at the template manifest file ``python3.manifest.template`` +Let's take a look at the template manifest file ``pytorch.manifest.template`` (recall that PyTorch is a collection of libraries and utilities but it uses Python as the actual executable). For illustrative purposes, we will look at only a few entries of the file. Note that we can simply ignore SGX-specific keys @@ -218,22 +218,18 @@ Now we can run ``make`` to build/copy all required Graphene files:: This command will autogenerate a couple new files: -#. Generate the actual non-SGX Graphene manifest (``python3.manifest``) from the +#. Generate the actual non-SGX Graphene manifest (``pytorch.manifest``) from the template manifest file. This file will be used by Graphene to decide on different manifest options how to execute PyTorch inside Graphene. #. Create a symbolic link to the generic Graphene loader (``pal_loader``). This is just for convenience. -#. Because Graphene requires 1-1 manifest-executable correspondence, it will - also create a symlink to the Python binary, with the name corresponding to - the manifest. - Now, launch Graphene via ``pal_loader``. You can simply append the arguments -after the executable name. Our example takes +after the application path. Our example takes ``pytorchexample.py`` as an argument:: - ./pal_loader ./python3 pytorchexample.py + ./pal_loader ./pytorch pytorchexample.py That's it. You have run the PyTorch example with Graphene. You can check ``result.txt`` to make sure it ran correctly. @@ -247,7 +243,7 @@ example inside an Intel SGX enclave. Let's go back to the manifest template these entries are ignored if Graphene runs in non-SGX mode). Below, we will highlight some of the SGX-specific manifest options in -``python3.manifest.template``. SGX syntax is fully described `here +``pytorch.manifest.template``. SGX syntax is fully described `here `__. First, here are the following SGX-specific lines in the manifest template:: @@ -293,12 +289,12 @@ an SGX enclave:: The above command performs the following tasks: -#. Generates the final SGX manifest file ``python3.manifest.sgx``. +#. Generates the final SGX manifest file ``pytorch.manifest.sgx``. #. Signs the manifest and generates the SGX signature file containing SIGSTRUCT - (``python3.sig``). + (``pytorch.sig``). -#. Creates a dummy EINITTOKEN token file ``python3.token`` (this file is used +#. Creates a dummy EINITTOKEN token file ``pytorch.token`` (this file is used for backwards compatibility with SGX platforms with EPID and without Flexible Launch Control). @@ -306,7 +302,7 @@ After running this command and building all the required files, we can simply set ``SGX=1`` environment variable and use ``pal_loader`` to launch the PyTorch workload inside an SGX enclave:: - SGX=1 ./pal_loader ./python3 pytorchexample.py + SGX=1 ./pal_loader ./pytorch pytorchexample.py It will run exactly the same Python script but inside the SGX enclave. Again, you can verify that PyTorch ran correctly by examining ``result.txt``. @@ -468,7 +464,7 @@ launch the server in the background. Preparing Manifest File ^^^^^^^^^^^^^^^^^^^^^^^ -Finally, let's modify the manifest file. Open ``python3.manifest.template`` +Finally, let's modify the manifest file. Open ``pytorch.manifest.template`` with your favorite text editor. Replace ``trusted_files`` with ``protected_files`` for the input files:: @@ -538,7 +534,7 @@ We are ready to run the end-to-end PyTorch example. Notice that we didn't change a line of code in the Python script. Moreover, we can run it with exactly the same command used in the previous section:: - SGX=1 ./pal_loader ./python3 pytorchexample.py + SGX=1 ./pal_loader ./pytorch pytorchexample.py This should run PyTorch with encrypted input files and generate the encrypted ``result.txt`` output file. Note that we already launched the secret diff --git a/Examples/apache/.gitignore b/Examples/apache/.gitignore index 7207733c..a50ad547 100644 --- a/Examples/apache/.gitignore +++ b/Examples/apache/.gitignore @@ -1,5 +1,4 @@ /*.tar.gz -/httpd /httpd-*/* /install/* /OUTPUT diff --git a/Examples/apache/Makefile b/Examples/apache/Makefile index e1797d81..dc923b74 100644 --- a/Examples/apache/Makefile +++ b/Examples/apache/Makefile @@ -38,7 +38,7 @@ GRAPHENEDEBUG = none endif .PHONY: all -all: $(INSTALL_DIR)/bin/httpd httpd.manifest config testdata ssldata | httpd pal_loader +all: $(INSTALL_DIR)/bin/httpd httpd.manifest config testdata ssldata | pal_loader ifeq ($(SGX),1) all: httpd.manifest.sgx httpd.sig httpd.token endif @@ -130,10 +130,8 @@ httpd.manifest.sgx: httpd.manifest $(INSTALL_DIR)/bin/httpd \ $(INSTALL_DIR)/conf/httpd-graphene.conf \ $(INSTALL_DIR)/conf/extra/httpd-ssl-graphene.conf \ $(TEST_DATA) \ - $(INSTALL_DIR)/conf/server.crt \ - | httpd + $(INSTALL_DIR)/conf/server.crt $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -exec httpd \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ -manifest httpd.manifest -output $@ @@ -143,9 +141,6 @@ httpd.sig: httpd.manifest.sgx httpd.token: httpd.sig $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $< -httpd: $(INSTALL_DIR)/bin/httpd - ln -s $< $@ - pal_loader: ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@ @@ -285,7 +280,7 @@ start-graphene-multithreaded-server: all clean-server .PHONY: clean clean: - $(RM) *.manifest *.manifest.sgx *.token *.sig httpd pal_loader OUTPUT result-* httpd-ldd \ + $(RM) *.manifest *.manifest.sgx *.token *.sig pal_loader OUTPUT result-* httpd-ldd \ httpd-modules tmp .PHONY: distclean diff --git a/Examples/apache/README.md b/Examples/apache/README.md index 6e336c9f..c9f32ee9 100644 --- a/Examples/apache/README.md +++ b/Examples/apache/README.md @@ -22,20 +22,20 @@ make SGX=1 # run original Apache against HTTP and HTTPS benchmarks (benchmark-http.sh, uses ab) make start-native-server & -./benchmark-http.sh 127.0.0.1:8001 -./benchmark-http.sh https://127.0.0.1:8443 +../common_tools/benchmark-http.sh 127.0.0.1:8001 +../common_tools/benchmark-http.sh https://127.0.0.1:8443 kill -SIGINT %% # run Apache in non-SGX Graphene against HTTP and HTTPS benchmarks make start-graphene-server & -./benchmark-http.sh 127.0.0.1:8001 -./benchmark-http.sh https://127.0.0.1:8443 +../common_tools/benchmark-http.sh 127.0.0.1:8001 +../common_tools/benchmark-http.sh https://127.0.0.1:8443 kill -SIGINT %% # run Apache in Graphene-SGX against HTTP and HTTPS benchmarks SGX=1 make start-graphene-server & -./benchmark-http.sh 127.0.0.1:8001 -./benchmark-http.sh https://127.0.0.1:8443 +../common_tools/benchmark-http.sh 127.0.0.1:8001 +../common_tools/benchmark-http.sh https://127.0.0.1:8443 kill -SIGINT %% # you can also test the server using other utilities like wget diff --git a/Examples/apache/benchmark-http.sh b/Examples/apache/benchmark-http.sh deleted file mode 120000 index 38087f85..00000000 --- a/Examples/apache/benchmark-http.sh +++ /dev/null @@ -1 +0,0 @@ -../common_tools/benchmark-http.sh \ No newline at end of file diff --git a/Examples/apache/httpd.manifest.template b/Examples/apache/httpd.manifest.template index 765880c7..6ed5adcd 100644 --- a/Examples/apache/httpd.manifest.template +++ b/Examples/apache/httpd.manifest.template @@ -2,14 +2,13 @@ # # This manifest was prepared and tested on Ubuntu 16.04. +loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" +libos.entrypoint = "file:$(INSTALL_DIR)/bin/httpd" loader.argv0_override = "httpd" # Read application arguments directly from the command line. Don't use this on production! loader.insecure__use_cmdline_argv = 1 -# Graphene environment, including the path to the library OS and the debug -# option (inline/none). -loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" loader.debug_type = "$(GRAPHENEDEBUG)" # Environment variables @@ -45,10 +44,12 @@ fs.mount.cwd.uri = "file:$(INSTALL_DIR)" # SGX general options +sgx.nonpie_binary = 1 + # Set the virtual memory size of the SGX enclave. For SGX v1, the enclave # size must be specified during signing. If Apache needs more virtual memory # than the enclave size, Graphene will not be able to allocate it. -sgx.enclave_size = "256M" +sgx.enclave_size = "512M" # Set the maximum number of enclave threads. For SGX v1, the number of enclave # TCSes must be specified during signing, so the application cannot use more @@ -61,7 +62,9 @@ sgx.enclave_size = "256M" # up to 25 threads/process. sgx.thread_num = 32 -# SGX trusted libraries +# SGX trusted files + +sgx.trusted_files.httpd = "file:$(INSTALL_DIR)/bin/httpd" # Glibc libraries sgx.trusted_files.ld = "file:$(GRAPHENEDIR)/Runtime/ld-linux-x86-64.so.2" diff --git a/Examples/bash/.gitignore b/Examples/bash/.gitignore index 71212577..d0a3788d 100644 --- a/Examples/bash/.gitignore +++ b/Examples/bash/.gitignore @@ -1,8 +1,2 @@ -/bash -/cat -/cp -/date -/ls /OUTPUT -/rm /scripts/testdir/* diff --git a/Examples/bash/Makefile b/Examples/bash/Makefile index 8dcd4514..376714b2 100644 --- a/Examples/bash/Makefile +++ b/Examples/bash/Makefile @@ -7,9 +7,6 @@ # # Use `make clean` to remove Graphene-generated files. -# Listing the programs to be run inside the bash script -PROGRAMS = ls cat rm cp date - # Relative path to Graphene root and key for enclave signing GRAPHENEDIR ?= ../.. SGX_SIGNER_KEY ?= $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/enclave-key.pem @@ -21,74 +18,33 @@ GRAPHENEDEBUG = none endif .PHONY: all -all: bash.manifest $(addsuffix .manifest,$(PROGRAMS)) | bash $(PROGRAMS) pal_loader +all: bash.manifest | pal_loader ifeq ($(SGX),1) -all: bash.token $(addsuffix .token,$(PROGRAMS)) +all: bash.manifest.sgx bash.sig bash.token endif include ../../Scripts/Makefile.configs -# Program dependencies (generate from ldd): -# -# For SGX, the manifest needs to list all the libraries loaded during the -# execution, so that the signer can include the file checksums. -# -# The dependencies are generated from the ldd results. +# Generate manifest rules for Bash dependencies. +# We'll duplicate some Glibc libraries (which Graphene provides in a customized version), but +# there's no harm in this. +PROGRAMS = bash ls cat rm cp date +.INTERMEDIATE: trusted-libs +trusted-libs: ../common_tools/get_deps.sh + ../common_tools/get_deps.sh $(foreach exec,$(PROGRAMS),$(shell which $(exec))) > $@ -# 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. This list also contains some runtime deps of Bash. -GLIBC_DEPS = linux-vdso /lib64/ld-linux-x86-64 libc libm librt libdl libutil libpthread \ - libselinux libpcre libacl libattr - -# Listing all Bash dependencies, besides Glibc libraries -.INTERMEDIATE: $(addsuffix .deps,bash $(PROGRAMS)) -%.deps: - ldd $(shell which $(basename $@)) | \ - awk '{if ($$2 =="=>") {split($$1,s,/\./); print s[1]}}' | \ - sort | uniq | (grep -v -x $(patsubst %,-e %,$(GLIBC_DEPS)) || true) > $@ - -# Generating manifest rules for Bash dependencies -.INTERMEDIATE: $(addsuffix .trusted-libs,bash $(PROGRAMS)) -%.trusted-libs: %.deps - for F in `cat $<`; do \ - P=`ldd $(shell which $(basename $@)) | grep $$F | awk '{print $$3; exit}'`; \ - N=`echo $$F | tr --delete '-'`; \ - echo -n "sgx.trusted_files.$$N = \\\"file:$$P\\\"\\\\n"; \ - done > $@ - -.INTERMEDIATE: trusted-children -trusted-children: - @for F in $(PROGRAMS); do \ - echo -n "sgx.trusted_children.$$F = \\\"file:$$F.sig\\\"\\\\n"; \ - echo -n "sgx.trusted_files.$$F = \\\"file:$$F\\\"\\\\n"; \ - done > $@ - -bash.manifest: manifest.template trusted-children bash.trusted-libs - sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ - -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ - -e 's|$$(ARGV0_OVERRIDE)|bash|g' \ - -e 's|$$(EXECDIR)|'"$(shell dirname $(shell which bash))"'|g' \ - -e 's|$$(TRUSTED_LIBS)|'"`cat bash.trusted-libs`"'|g' \ - -e 's|$$(TRUSTED_CHILDREN)|'"`cat trusted-children`"'|g' \ - -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ - -$(addsuffix .manifest,$(PROGRAMS)): %.manifest: manifest.template %.trusted-libs - sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ - -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ - -e 's|$$(ARGV0_OVERRIDE)|'"$(basename $@)"'|g' \ - -e 's|$$(EXECDIR)|'"$(shell dirname $(shell which $(basename $@)))"'|g' \ - -e 's|$$(TRUSTED_LIBS)|'"`cat $(basename $@).trusted-libs`"'|g' \ - -e 's|$$(TRUSTED_CHILDREN)||g' \ - -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ +bash.manifest: manifest.template trusted-libs + (sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ + -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ + -e 's|$$(EXECDIR)|'"$(shell dirname $(shell which bash))"'|g' \ + -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ + $<; \ + cat trusted-libs) > $@ # Generating the SGX-specific manifest (*.manifest.sgx), the enclave signature, # and the token for enclave initialization. -bash.manifest.sgx: bash.manifest $(addsuffix .manifest.sgx,$(PROGRAMS)) | bash +bash.manifest.sgx: bash.manifest $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -exec bash \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ -manifest bash.manifest -output $@ @@ -99,23 +55,6 @@ bash.token: bash.sig $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \ -output bash.token -sig bash.sig -$(addsuffix .manifest.sgx,$(PROGRAMS)): %.manifest.sgx: % %.manifest - $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -exec $* \ - -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ - -key $(SGX_SIGNER_KEY) \ - -manifest $*.manifest \ - -output $@ - -$(addsuffix .sig,$(PROGRAMS)): %.sig: %.manifest.sgx - -$(addsuffix .token,$(PROGRAMS)): %.token: %.sig - $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \ - -output $(basename $<).token -sig $(basename $<).sig - -bash $(PROGRAMS): - ln -s "$(shell which $@)" $@ - pal_loader: ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@ @@ -143,8 +82,7 @@ regression: all .PHONY: clean clean: - $(RM) *.manifest *.manifest.sgx *.token *.sig bash $(PROGRAMS) pal_loader OUTPUT \ - scripts/testdir/* + $(RM) *.manifest *.manifest.sgx *.token *.sig trusted-libs pal_loader OUTPUT scripts/testdir/* .PHONY: distclean distclean: clean diff --git a/Examples/bash/manifest.template b/Examples/bash/manifest.template index e893d57d..66376c73 100644 --- a/Examples/bash/manifest.template +++ b/Examples/bash/manifest.template @@ -2,20 +2,17 @@ # including ls, cat, cp, date, and rm. # # This manifest was prepared and tested on Ubuntu 16.04. - -loader.argv0_override = "$(ARGV0_OVERRIDE)" +loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" +libos.entrypoint = "file:$(EXECDIR)/bash" # Read application arguments directly from the command line. Don't use this on production! loader.insecure__use_cmdline_argv = 1 -# Graphene environment, including the path of the library OS and the debug -# option (inline/none). -loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" loader.debug_type = "$(GRAPHENEDEBUG)" # Environment variables -loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR)" -loader.env.PATH = "/" +loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR):/usr$(ARCH_LIBDIR)" +loader.env.PATH = "$(EXECDIR)" # Mounted FSes. The following "chroot" FSes mount a part of the host FS into the # guest. Other parts of the host FS will not be available in the guest. @@ -26,6 +23,14 @@ fs.mount.lib.path = "/lib" fs.mount.lib.uri = "file:$(GRAPHENEDIR)/Runtime" # Host-level libraries (e.g., /lib/x86_64-linux-gnu) required by Bash +fs.mount.lib64.type = "chroot" +fs.mount.lib64.path = "/lib64" +fs.mount.lib64.uri = "file:/lib64" + +fs.mount.usr_lib.type = "chroot" +fs.mount.usr_lib.path = "/usr/lib" +fs.mount.usr_lib.uri = "file:/usr/lib" + fs.mount.lib2.type = "chroot" fs.mount.lib2.path = "$(ARCH_LIBDIR)" fs.mount.lib2.uri = "file:$(ARCH_LIBDIR)" @@ -50,7 +55,14 @@ sgx.enclave_size = "256M" # the application can create is (sgx.thread_num - 2). sgx.thread_num = 4 -# SGX trusted libraries +# SGX trusted files + +sgx.trusted_files.bash = "file:$(EXECDIR)/bash" +sgx.trusted_files.ls = "file:$(EXECDIR)/ls" +sgx.trusted_files.cat = "file:$(EXECDIR)/cat" +sgx.trusted_files.rm = "file:$(EXECDIR)/rm" +sgx.trusted_files.cp = "file:$(EXECDIR)/cp" +sgx.trusted_files.date = "file:$(EXECDIR)/date" # Glibc libraries sgx.trusted_files.ld = "file:$(GRAPHENEDIR)/Runtime/ld-linux-x86-64.so.2" @@ -66,16 +78,6 @@ sgx.trusted_files.libnsscompat = "file:$(ARCH_LIBDIR)/libnss_compat.so.2" sgx.trusted_files.libnssfiles = "file:$(ARCH_LIBDIR)/libnss_files.so.2" sgx.trusted_files.libnssnis = "file:$(ARCH_LIBDIR)/libnss_nis.so.2" -# Additional libs opened by Bash at runtime -sgx.trusted_files.libselinux1 = "file:$(ARCH_LIBDIR)/libselinux.so.1" -sgx.trusted_files.libpcre = "file:$(ARCH_LIBDIR)/libpcre.so.3" -sgx.trusted_files.libacl = "file:$(ARCH_LIBDIR)/libacl.so.1" -sgx.trusted_files.libattr = "file:$(ARCH_LIBDIR)/libattr.so.1" - -# Other required libraries -$(TRUSTED_LIBS) - -# Signatures of child enclaves -$(TRUSTED_CHILDREN) - sgx.allowed_files.scripts = "file:scripts" + +sgx.nonpie_binary = 1 diff --git a/Examples/blender/Makefile b/Examples/blender/Makefile index 41828292..a786221f 100644 --- a/Examples/blender/Makefile +++ b/Examples/blender/Makefile @@ -14,10 +14,11 @@ RUN_DIR = $(PWD)/run_dir UBUNTU_VER = $(shell lsb_release --short --id)$(shell lsb_release --short --release) -ifeq ($(UBUNTU_VER), Ubuntu18.04) +ifeq ($(UBUNTU_VER), Ubuntu20.04) +else ifeq ($(UBUNTU_VER), Ubuntu18.04) else ifeq ($(UBUNTU_VER), Ubuntu16.04) else -$(error This example requires Ubuntu 16.04 or 18.04) +$(error This example requires Ubuntu 16.04, 18.04 or 20.04) endif ifeq ($(DEBUG),1) @@ -28,9 +29,9 @@ endif .PHONY: all -all: $(BLENDER_DIR)/blender $(BLENDER_DIR)/blender.manifest | $(RUN_DIR)/pal_loader $(DATA_DIR)/images +all: $(BLENDER_DIR)/blender blender.manifest | $(RUN_DIR)/pal_loader $(DATA_DIR)/images ifeq ($(SGX),1) -all: $(BLENDER_DIR)/blender.token +all: blender.manifest.sgx blender.sig blender.token endif include ../../Scripts/Makefile.configs @@ -44,29 +45,30 @@ $(BLENDER_DIR)/blender: $(RUN_DIR): mkdir -p $@ -$(BLENDER_DIR)/blender.manifest: blender.manifest.template $(BLENDER_DIR)/blender | $(RUN_DIR) - sed -e 's|$$(GRAPHENE_DIR)|'"$(GRAPHENE_DIR)"'|g' \ - -e 's|$$(GRAPHENE_DEBUG)|'"$(GRAPHENE_DEBUG)"'|g' \ - -e 's|$$(DATA_DIR)|'"$(DATA_DIR)"'|g' \ - -e 's|$$(BLENDER_DIR)|'"$(BLENDER_DIR)"'|g' \ - -e 's|$$(BLENDER_VER)|'"$(BLENDER_VER)"'|g' \ - -e 's|# \['"$(UBUNTU_VER)"'\] ||g' \ - -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ +.INTERMEDIATE: trusted-libs +trusted-libs: ../common_tools/get_deps.sh $(BLENDER_DIR)/blender + ../common_tools/get_deps.sh $(BLENDER_DIR)/blender > $@ -$(BLENDER_DIR)/blender.manifest.sgx: $(BLENDER_DIR)/blender $(BLENDER_DIR)/blender.manifest \ +blender.manifest: blender.manifest.template trusted-libs | $(RUN_DIR) + (sed -e 's|$$(GRAPHENE_DIR)|'"$(GRAPHENE_DIR)"'|g' \ + -e 's|$$(GRAPHENE_DEBUG)|'"$(GRAPHENE_DEBUG)"'|g' \ + -e 's|$$(DATA_DIR)|'"$(DATA_DIR)"'|g' \ + -e 's|$$(BLENDER_DIR)|'"$(BLENDER_DIR)"'|g' \ + -e 's|$$(BLENDER_VER)|'"$(BLENDER_VER)"'|g' \ + -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ + $<; \ + cat trusted-libs) > $@ + +blender.sig blender.manifest.sgx &: $(BLENDER_DIR)/blender blender.manifest \ $(GRAPHENE_DIR)/Runtime/libpal-Linux-SGX.so | $(RUN_DIR) $(GRAPHENE_DIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -output $@ \ + -output blender.manifest.sgx \ -libpal $(GRAPHENE_DIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ - -manifest $(BLENDER_DIR)/blender.manifest \ - -exec $< + -manifest blender.manifest -$(BLENDER_DIR)/blender.token: $(BLENDER_DIR)/blender.manifest.sgx - $(GRAPHENE_DIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \ - -output $@ \ - -sig $(BLENDER_DIR)/blender.sig +blender.token: blender.sig + $(GRAPHENE_DIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $< $(RUN_DIR)/pal_loader: | $(RUN_DIR) ln -s $(GRAPHENE_DIR)/Runtime/pal_loader $@ @@ -76,14 +78,12 @@ $(DATA_DIR)/images: .PHONY: check check: all - cd $(RUN_DIR) && BLENDER_DIR=$(BLENDER_DIR) DATA_DIR=$(DATA_DIR) \ - sh $(PWD)/test_all_scenes.sh + cd $(RUN_DIR) && DATA_DIR=$(DATA_DIR) sh $(PWD)/test_all_scenes.sh .PHONY: clean clean: - $(RM) -r $(RUN_DIR) $(DATA_DIR)/images $(BLENDER_DIR)/blender.manifest \ - $(BLENDER_DIR)/blender.manifest.sgx $(BLENDER_DIR)/blender.sig \ - $(BLENDER_DIR)/blender.token + $(RM) -r $(RUN_DIR) $(DATA_DIR)/images blender.manifest blender.manifest.sgx blender.sig \ + blender.token trusted-libs .PHONY: distclean distclean: clean diff --git a/Examples/blender/blender.manifest.template b/Examples/blender/blender.manifest.template index 5ce73d29..f664f42f 100644 --- a/Examples/blender/blender.manifest.template +++ b/Examples/blender/blender.manifest.template @@ -11,7 +11,7 @@ sgx.allowed_files.blender_input = "file:$(DATA_DIR)/scenes/" sgx.allowed_files.blender_output = "file:$(DATA_DIR)/images/" -loader.argv0_override = "blender" +libos.entrypoint = "file:$(BLENDER_DIR)/blender" # Read application arguments directly from the command line. Don't use this on production! loader.insecure__use_cmdline_argv = 1 @@ -51,11 +51,11 @@ fs.mount.blender.uri = "file:$(BLENDER_DIR)" sys.stack.size = "8M" - sgx.enclave_size = "2048M" sgx.thread_num = 64 +sgx.nonpie_binary = 1 - +sgx.trusted_files.blender = "file:$(BLENDER_DIR)/blender" sgx.trusted_files.ld = "file:$(GRAPHENE_DIR)/Runtime/ld-linux-x86-64.so.2" sgx.trusted_files.libc = "file:$(GRAPHENE_DIR)/Runtime/libc.so.6" sgx.trusted_files.libdl = "file:$(GRAPHENE_DIR)/Runtime/libdl.so.2" @@ -64,22 +64,9 @@ sgx.trusted_files.libpthread = "file:$(GRAPHENE_DIR)/Runtime/libpthread.so.0" sgx.trusted_files.libutil = "file:$(GRAPHENE_DIR)/Runtime/libutil.so.1" sgx.trusted_files.librt = "file:$(GRAPHENE_DIR)/Runtime/librt.so.1" +# Loaded in runtime, ldd doesn't list them. +sgx.trusted_files.libnuma = "file:/usr/$(ARCH_LIBDIR)/libnuma.so.1" sgx.trusted_files.libGL = "file:$(BLENDER_DIR)/lib/libGL.so.1" sgx.trusted_files.libglapi = "file:$(BLENDER_DIR)/lib/libglapi.so.0" - -sgx.trusted_files.libX11 = "file:/usr/$(ARCH_LIBDIR)/libX11.so.6" -sgx.trusted_files.libXi = "file:/usr/$(ARCH_LIBDIR)/libXi.so.6" -sgx.trusted_files.libXxf86vm = "file:/usr/$(ARCH_LIBDIR)/libXxf86vm.so.1" -sgx.trusted_files.libXfixes = "file:/usr/$(ARCH_LIBDIR)/libXfixes.so.3" -sgx.trusted_files.libXrender = "file:/usr/$(ARCH_LIBDIR)/libXrender.so.1" -sgx.trusted_files.libgcc_s = "file:$(ARCH_LIBDIR)/libgcc_s.so.1" sgx.trusted_files.libz = "file:$(ARCH_LIBDIR)/libz.so.1" -sgx.trusted_files.libXext = "file:/usr/$(ARCH_LIBDIR)/libXext.so.6" -sgx.trusted_files.libxcb = "file:/usr/$(ARCH_LIBDIR)/libxcb.so.1" -sgx.trusted_files.libXau = "file:/usr/$(ARCH_LIBDIR)/libXau.so.6" -sgx.trusted_files.libXdmcp = "file:/usr/$(ARCH_LIBDIR)/libXdmcp.so.6" sgx.trusted_files.libstdcpp = "file:/usr/$(ARCH_LIBDIR)/libstdc++.so.6" -sgx.trusted_files.libnuma = "file:/usr/$(ARCH_LIBDIR)/libnuma.so.1" - -# Ubuntu version specific files -# [Ubuntu18.04] sgx.trusted_files.libbsd = "file:$(ARCH_LIBDIR)/libbsd.so.0" diff --git a/Examples/blender/test_all_scenes.sh b/Examples/blender/test_all_scenes.sh index 6a6d89f3..7e98514c 100755 --- a/Examples/blender/test_all_scenes.sh +++ b/Examples/blender/test_all_scenes.sh @@ -5,7 +5,7 @@ set -e for i in `ls "$DATA_DIR"/scenes/`; do rm -f "$DATA_DIR"/images/"$i"0001.png - ./pal_loader "$BLENDER_DIR/blender" -b /data/scenes/$i -t 4 -F PNG -o /data/images/$i -f 1 + ./pal_loader "../blender" -b /data/scenes/$i -t 4 -F PNG -o /data/images/$i -f 1 # TODO add a better test, probably some diff with a precomputed image [ -f "$DATA_DIR"/images/"$i"0001.png ] done diff --git a/Examples/busybox/Makefile b/Examples/busybox/Makefile index c085a3b9..5f38ae97 100644 --- a/Examples/busybox/Makefile +++ b/Examples/busybox/Makefile @@ -30,7 +30,7 @@ endif .PHONY: all all: busybox busybox.manifest pal_loader ifeq ($(SGX),1) -all: busybox.manifest.sgx +all: busybox.manifest.sgx busybox.sig busybox.token endif include ../../Scripts/Makefile.configs @@ -73,23 +73,22 @@ busybox.manifest: busybox.manifest.template -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ $< > $@ -# Manifest for Graphene-SGX requires special "pal-sgx-sign" procedure. This -# procedure measures all Busybox dependencies (shared libraries and trusted -# files), measures Busybox code/data pages, and adds measurements into the -# resulting manifest.sgx file (among other, less important SGX options). +# Manifest for Graphene-SGX requires special "pal-sgx-sign" procedure. This procedure measures all +# Busybox trusted files, adds the measurement to the resulting manifest.sgx file (among other, +# less important SGX options) and creates busybox.sig (SIGSTRUCT object). # -# Additionally, Graphene-SGX requires EINITTOKEN and SIGSTRUCT objects (see -# SGX hardware ABI, in particular EINIT instruction). The "pal-sgx-get-token" -# script generates these objects and puts them in files .token and .sig -# respectively. Note that filenames must be the same as the executable/manifest -# name (i.e., "busybox"). +# Graphene-SGX requires EINITTOKEN and SIGSTRUCT objects (see SGX hardware ABI, in particular EINIT +# instruction). The "pal-sgx-get-token" script generates EINITTOKEN based on a SIGSTRUCT and puts it +# in .token file. Note that filenames must be the same as the manifest name (i.e., "busybox"). +# EINITTOKEN must be generated on the machine where the application will run, not where it was +# built. + busybox.manifest.sgx: busybox.manifest busybox $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ - -manifest $< -output $@ \ - -exec busybox + -manifest $< -output $@ $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \ -output busybox.token -sig busybox.sig diff --git a/Examples/busybox/busybox.manifest.template b/Examples/busybox/busybox.manifest.template index 257bb8fb..7864c213 100644 --- a/Examples/busybox/busybox.manifest.template +++ b/Examples/busybox/busybox.manifest.template @@ -4,6 +4,9 @@ ################################## GRAPHENE ################################### +# The binary to execute. +libos.entrypoint = "file:busybox" + # Read application arguments directly from the command line. Don't use this on production! loader.insecure__use_cmdline_argv = 1 @@ -65,11 +68,11 @@ fs.mount.etc.type = "chroot" fs.mount.etc.path = "/etc" fs.mount.etc.uri = "file:/etc" -############################# SGX: TRUSTED LIBS ############################### +############################# SGX: TRUSTED FILES ############################### -# Specify all libraries used by Busybox and its dependencies (including all -# libraries which can be loaded at runtime via dlopen). The paths to libraries -# are host-OS paths. These libraries will be searched for in in-Graphene +# Specify all files used by Busybox and its dependencies (including all +# libraries which can be loaded at runtime via dlopen). The paths to files +# are host-OS paths. These files will be searched for in in-Graphene # visible paths according to mount points above. # # As part of the build process, Graphene-SGX script (`pal-sgx-sign`) finds each @@ -77,10 +80,12 @@ fs.mount.etc.uri = "file:/etc" # entry 'sgx.trusted_checksum.xxx' in auto-generated 'busybox.manifest.sgx' # file. Note that this happens on the developer's machine. # -# At runtime, during loading of this library, Graphene-SGX measures its hash -# and compares it with the one specified in 'sgx.trusted_checksum.xxx'. If both -# hashes match, this library is trusted and allowed to be loaded and used. Note -# that this happens on the client machine. +# At runtime, during loading of each "trusted file", Graphene-SGX measures its hash +# and compares with the one specified in 'sgx.trusted_checksum.xxx'. If hashes +# match, this file is trusted and allowed to be loaded and used. Note that +# this happens on the client machine. + +sgx.trusted_files.busybox = "file:busybox" # Glibc libraries. sgx.trusted_files.ld = "file:$(GRAPHENEDIR)/Runtime/ld-linux-x86-64.so.2" @@ -105,9 +110,8 @@ sgx.trusted_files.libnssnis = "file:$(ARCH_LIBDIR)/libnss_nis.so.2" # library dependencies required by Graphene-SGX. sgx.trusted_files.libnsl = "file:$(ARCH_LIBDIR)/libnsl.so.1" -############################ SGX: TRUSTED FILES ############################### -# Trusted no-library files include configuration files, read-only files, and +# Trusted non-library files include configuration files, read-only files, and # other static files. It is useful to specify such files here to make sure # they are not maliciously modified (modifications will be detected as hash # mismatch by Graphene-SGX). diff --git a/Examples/capnproto/Makefile b/Examples/capnproto/Makefile index c693dc21..6085754e 100644 --- a/Examples/capnproto/Makefile +++ b/Examples/capnproto/Makefile @@ -30,10 +30,10 @@ else GRAPHENEDEBUG = none endif -.PHONY=all +.PHONY: all all: addressbook addressbook.manifest pal_loader ifeq ($(SGX),1) -all: addressbook.token +all: addressbook.manifest.sgx addressbook.sig addressbook.token endif include ../../Scripts/Makefile.configs @@ -53,48 +53,31 @@ $(SRCDIR)/addressbook: $(SRCDIR)/addressbook.c++ $(SRCDIR)/addressbook.capnp cd $(SRCDIR) && c++ -std=c++14 -Wall addressbook.c++ addressbook.capnp.c++ \ `pkg-config --cflags --libs capnp` -o addressbook -# Addressbook dependencies (from ldd); needed for concrete versions of libcapnp.so and libkj.so +# Generate manifest rules for Addressbook 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 $(SRCDIR)/addressbook + ../common_tools/get_deps.sh $(SRCDIR)/addressbook > $@ -# 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 Addressbook dependencies, besides Glibc libraries -.INTERMEDIATE: addressbook-deps -addressbook-deps: $(SRCDIR)/addressbook - @ldd $(SRCDIR)/addressbook | \ - awk '{if ($$2 =="=>") {print $$1}}' | \ - sort | uniq | grep -v -x $(patsubst %,-e %,$(GLIBC_DEPS)) > $@ - -# Generate manifest rules for Addressbook dependencies -.INTERMEDIATE: addressbook-trusted-libs -addressbook-trusted-libs: addressbook-deps - @for F in `cat addressbook-deps`; do \ - P=`ldd $(SRCDIR)/addressbook | 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 > $@ - -addressbook.manifest: addressbook.manifest.template addressbook-trusted-libs - sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ +addressbook.manifest: addressbook.manifest.template trusted-libs + (sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ - -e 's|$$(TRUSTEDLIBS)|'"`cat addressbook-trusted-libs`"'|g' \ -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ + $<; \ + cat trusted-libs) > $@ addressbook.manifest.sgx: addressbook.manifest addressbook $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ - -manifest $< -output $@ \ - -exec $(SRCDIR)/addressbook + -manifest $< -output $@ addressbook.sig: addressbook.manifest.sgx addressbook.token: addressbook.sig - $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \ - -output $@ -sig $^ + $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $^ addressbook: $(SRCDIR)/addressbook cp $< $@ @@ -102,10 +85,10 @@ addressbook: $(SRCDIR)/addressbook pal_loader: ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@ -.PHONY=clean +.PHONY: clean clean: $(RM) *.token *.sig *.manifest.sgx *.manifest pal_loader addressbook -.PHONY=distclean +.PHONY: distclean distclean: clean $(RM) -r $(SRCDIR) diff --git a/Examples/capnproto/addressbook.manifest.template b/Examples/capnproto/addressbook.manifest.template index 2f49d83c..55a05857 100644 --- a/Examples/capnproto/addressbook.manifest.template +++ b/Examples/capnproto/addressbook.manifest.template @@ -2,6 +2,9 @@ # # This manifest was prepared and tested on Ubuntu 16.04 and Ubuntu 18.04. +# The binary to execute. +libos.entrypoint = "file:addressbook" + # LibOS layer library of Graphene (currently only one implementation, libsysdb) loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" @@ -40,9 +43,12 @@ sgx.enclave_size = "256M" # Set maximum number of in-enclave threads (somewhat arbitrarily) to 8 sgx.thread_num = 8 +sgx.trusted_files.addressbook = "file:addressbook" + # Glibc libraries 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" sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0" -$(TRUSTEDLIBS) +sgx.trusted_files.libstdcpp = "file:$(GRAPHENEDIR)/Runtime/libstdc++.so.6" +sgx.trusted_files.libgcc_s = "file:$(GRAPHENEDIR)/Runtime/libgcc_s.so.1" diff --git a/Examples/common_tools/get_deps.sh b/Examples/common_tools/get_deps.sh new file mode 100755 index 00000000..a221f8b4 --- /dev/null +++ b/Examples/common_tools/get_deps.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-3.0-or-later */ +# Copyright (C) 2020 Intel Corporation +# MichaƂ Kowalczyk + +set -eu -o pipefail + +# Arguments: binaries for which to generate manifest trusted files list. + +# Be careful: We have to skip vdso, which doesn't have a corresponding file on the disk (we assume +# that such files have paths starting with '/', seems ldd aways prints absolute paths). Also, old +# ldd (from Ubuntu 16.04) prints vdso differently than newer ones: +# old: +# linux-vdso.so.1 => (0x00007ffd31fee000) +# new: +# linux-vdso.so.1 (0x00007ffd31fee000) +DEPS=$(ldd "$@" \ + | awk '{ + if ($2 == "=>" && $3 ~ /^\/.*$/) { + print $3 + } else if ($1 ~ /^\/.*$/ && $2 ~ /^\(.+\)$/) { + print $1 + } + }' \ + | sort | uniq) + +for DEP in $DEPS; do + # generate Graphene manifest line + echo "sgx.trusted_files.\"$DEP\" = \"file:$DEP\"" +done diff --git a/Examples/curl/.gitignore b/Examples/curl/.gitignore index 396d3690..32b966bc 100644 --- a/Examples/curl/.gitignore +++ b/Examples/curl/.gitignore @@ -1,2 +1 @@ -/curl /OUTPUT diff --git a/Examples/curl/Makefile b/Examples/curl/Makefile index 53bdeb1d..bca7dd52 100644 --- a/Examples/curl/Makefile +++ b/Examples/curl/Makefile @@ -21,49 +21,31 @@ GRAPHENEDEBUG = none endif .PHONY: all -all: curl.manifest curl pal_loader +all: curl.manifest pal_loader ifeq ($(SGX),1) -all: curl.token +all: curl.manifest.sgx curl.sig curl.token endif include ../../Scripts/Makefile.configs -# curl 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 curl 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 $(CURL_DIR)/curl > $@ -# 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 curl dependencies, besides Glibc libraries -.INTERMEDIATE: curl-deps -curl-deps: - @ldd $(CURL_DIR)/curl | \ - awk '{if ($$2 =="=>") {print $$1}}' | \ - sort | uniq | grep -v -x $(patsubst %,-e %,$(GLIBC_DEPS)) > $@ - -# Generate manifest rules for curl dependencies -.INTERMEDIATE: curl-trusted-libs -curl-trusted-libs: curl-deps - @for F in `cat curl-deps`; do \ - P=`ldd $(CURL_DIR)/curl | grep $$F | awk '{print $$3; exit}'`; \ - N=`echo $$F | tr --delete '.' | tr --delete '-'`; \ - echo -n "sgx.trusted_files.$$N = \\\"file:$$P\\\"\\\\n"; \ - done > $@ - -curl.manifest: curl.manifest.template curl-trusted-libs - @sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ - -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ - -e 's|$$(CURL_DIR)|'"$(CURL_DIR)"'|g' \ - -e 's|$$(CURL_TRUSTED_LIBS)|'"`cat curl-trusted-libs`"'|g' \ - -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ +curl.manifest: curl.manifest.template trusted-libs + (sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ + -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ + -e 's|$$(CURL_DIR)|'"$(CURL_DIR)"'|g' \ + -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ + $<; \ + cat trusted-libs) > $@ # Generate SGX-specific manifest, enclave signature, and token for enclave initialization -curl.manifest.sgx: curl curl.manifest +curl.manifest.sgx: curl.manifest $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -exec curl \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ -manifest curl.manifest -output $@ @@ -71,11 +53,7 @@ curl.manifest.sgx: curl curl.manifest curl.sig: curl.manifest.sgx curl.token: curl.sig - $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token \ - -output $@ -sig $^ - -curl: - ln -s $(CURL_DIR)/curl $@ + $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $^ pal_loader: ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@ @@ -92,7 +70,7 @@ check: all .PHONY: clean clean: - $(RM) *.manifest *.manifest.sgx *.token *.sig curl pal_loader OUTPUT + $(RM) *.manifest *.manifest.sgx *.token *.sig pal_loader OUTPUT .PHONY: distclean distclean: clean diff --git a/Examples/curl/curl.manifest.template b/Examples/curl/curl.manifest.template index 1073cbf5..cf629b20 100644 --- a/Examples/curl/curl.manifest.template +++ b/Examples/curl/curl.manifest.template @@ -2,6 +2,7 @@ # # This manifest was prepared and tested on Ubuntu 16.04. +libos.entrypoint = "file:$(CURL_DIR)/curl" loader.argv0_override = "curl" # LibOS layer library of Graphene. There is currently only one implementation, @@ -50,8 +51,9 @@ sgx.enclave_size = "256M" # enclave creation time. sgx.thread_num = 4 -# Specify all libraries used by curl and its dependencies (including all libs +# Specify all binaries used by curl and its dependencies (including all libs # which can be loaded at runtime via dlopen). +sgx.trusted_files.curl = "file:$(CURL_DIR)/curl" 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" @@ -63,7 +65,6 @@ sgx.trusted_files.libresolv = "file:$(GRAPHENEDIR)/Runtime/libresolv.so.2" sgx.trusted_files.libnssdns = "file:$(GRAPHENEDIR)/Runtime/libnss_dns.so.2" sgx.trusted_files.libnss_files = "file:$(ARCH_LIBDIR)/libnss_files.so.2" sgx.trusted_files.libnss_mdns4_minimal = "file:$(ARCH_LIBDIR)/libnss_mdns4_minimal.so.2" -$(CURL_TRUSTED_LIBS) # Name Service Switch (NSS) files. Glibc reads these files as part of name- # service information gathering. For more info, see 'man nsswitch.conf'. diff --git a/Examples/gcc/.gitignore b/Examples/gcc/.gitignore deleted file mode 100644 index 23929723..00000000 --- a/Examples/gcc/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/cc1-trusted-libs -/as -/cc1 -/collect2 -/gcc -/ld diff --git a/Examples/gcc/Makefile b/Examples/gcc/Makefile index 5fb69237..cc4d0ad8 100644 --- a/Examples/gcc/Makefile +++ b/Examples/gcc/Makefile @@ -16,68 +16,55 @@ endif include ../../Scripts/Makefile.configs -# All the tools/executables required for this example (alphabetic order). -TOOLS = as cc1 collect2 gcc ld - # awk '{print $NF}' ... print last field. BINUTILS_VERSION ?= $(shell ld -v | awk '{print $$NF}') GCC_MAJOR_VERSION ?= $(shell gcc -v 2>&1 | tail -n1 | awk '{print $$3}' | awk 'BEGIN {FS="."}{print $$1}') GCC_LIB_PATH ?= /usr/lib/gcc/$(ARCH_LONG) .PHONY: all -all: $(addsuffix .manifest, $(TOOLS)) test_files/bzip2.c test_files/gzip.c | $(TOOLS) pal_loader +all: gcc.manifest test_files/bzip2.c test_files/gzip.c | pal_loader ifeq ($(SGX),1) -all: $(addsuffix .token, $(TOOLS)) +all: gcc.manifest.sgx gcc.sig gcc.token endif -%.manifest: %.manifest.template - sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ +# Generate manifest rules for Bash dependencies. +# We'll duplicate some Glibc libraries (which Graphene provides in a customized version), but +# there's no harm in this. +PROGRAMS = /usr/bin/gcc \ + $(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/cc1 \ + $(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/collect2 \ + /usr/bin/as \ + /usr/bin/ld +.INTERMEDIATE: trusted-libs +trusted-libs: ../common_tools/get_deps.sh + ../common_tools/get_deps.sh $(PROGRAMS) > $@ + +%.manifest: %.manifest.template trusted-libs + (sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ -e 's|$$(BINUTILS_VERSION)|'"$(BINUTILS_VERSION)"'|g' \ -e 's|$$(GCC_MAJOR_VERSION)|'"$(GCC_MAJOR_VERSION)"'|g' \ -e 's|$$(GCC_LIB_PATH)|'"$(GCC_LIB_PATH)"'|g' \ - -e 's|$$(CC1_TRUSTED_LIBS)|'"`cat cc1-trusted-libs`"'|g' \ -e 's|$$(LD_TRUSTED_FILES)|'"`cat ld-gcc-$(GCC_MAJOR_VERSION)-trusted-files`"'|g' \ -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ - -# Prevent .manifest/.manifest.sgx from automatically being deleted by make -.SECONDARY: $(addsuffix .manifest.sgx, $(TOOLS)) -.SECONDARY: $(addsuffix .manifest, $(TOOLS)) -.SECONDARY: gcc.sig + $<; \ + cat trusted-libs) > $@ # Rules to generate the SGX-specific manifest (.manifest.sgx), the enclave signature (.sig), and the # enclave initialization token (.token). -%.manifest.sgx: % %.manifest +gcc.sig gcc.manifest.sgx &: gcc.manifest $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -exec $* \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ - -manifest $*.manifest -output $@ - -# .sig file is actually generated by the above target %.manifest.sgx. The %.sig target is required -# make `make` aware of this. Also, the target must actually have at least one command, otherwise it -# does not work as intended. -%.sig: %.manifest.sgx - @echo -n "" + -manifest gcc.manifest \ + -output gcc.manifest.sgx %.token: %.sig $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $< -as gcc ld: - ln -s /usr/bin/$@ $@ - -cc1 collect2: - ln -s $(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/$@ $@ - pal_loader: ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@ -# Dependencies between the various tools. -gcc.manifest.sgx: as.sig cc1.sig collect2.sig -collect2.manifest.sgx: ld.sig -cc1.manifest: cc1-trusted-libs - test_files/bzip2.c: $(GRAPHENEDIR)/Scripts/download --output $@ --sha256 $(BZIP2_HASH) --url $(BZIP2_URL) @@ -88,40 +75,16 @@ test_files/gzip_broken.c: test_files/gzip.c: test_files/gzip_broken.c test_files/gzip.patch patch test_files/gzip_broken.c -i test_files/gzip.patch -o $@ -# 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 /lib64/ld-linux-x86-64 libc libm librt libdl libutil libpthread - -# List all the cc1 dependencies, besides Glibc libraries -.INTERMEDIATE: cc1-ldd -cc1-ldd: cc1 -%-ldd: - @for F in $^; do \ - ldd $$F >> $@ || exit 1; done - -%-deps: %-ldd - cat $< | awk '{if ($$2 =="=>") {split($$1,s,/\./); print s[1]}}' \ - | sort | uniq | grep -v -x $(patsubst %,-e %,$(GLIBC_DEPS)) > $@ - -# Generate manifest rules for trusted shared libraries -%-trusted-libs: %-deps - for F in `cat $<`; do \ - P=`cat $*-ldd | grep $$F | awk '{print $$3; exit}'`; \ - N=`echo $$F | tr --delete '-'`; \ - echo -n "sgx.trusted_files.$$N = \\\"file:$$P\\\"\\\\n"; \ - done > $@ - .PHONY: check check: all @echo "\n\nCompiling hello.c..." - ./pal_loader ./gcc test_files/helloworld.c -o test_files/hello + ./pal_loader gcc test_files/helloworld.c -o test_files/hello @chmod 755 test_files/hello -./test_files/hello $(RM) test_files/hello @echo "\n\nCompiling bzip2.c..." - ./pal_loader ./gcc test_files/bzip2.c -o test_files/bzip2 + ./pal_loader gcc test_files/bzip2.c -o test_files/bzip2 @chmod 755 test_files/bzip2 $(RM) bzip2.tmp @cp -f test_files/bzip2 test_files/bzip2.copy @@ -131,7 +94,7 @@ check: all $(RM) test_files/bzip2 test_file/bzip2.copy @echo "\n\nCompiling gzip.c..." - ./pal_loader ./gcc test_files/gzip.c -o test_files/gzip + ./pal_loader gcc test_files/gzip.c -o test_files/gzip @chmod 755 test_files/gzip @cp -f test_files/gzip test_files/gzip.copy ./test_files/gzip test_files/gzip.copy @@ -141,8 +104,7 @@ check: all .PHONY: clean clean: - $(RM) *.manifest *.manifest.sgx *.sig *.token $(TOOLS) pal_loader - $(RM) *-deps *-ldd *-trusted-libs + $(RM) *.manifest *.manifest.sgx *.sig *.token pal_loader trusted-libs $(RM) test_files/gzip.copy test_files/bzip2.copy .PHONY: distclean diff --git a/Examples/gcc/README.md b/Examples/gcc/README.md index 24c9194d..891629e7 100644 --- a/Examples/gcc/README.md +++ b/Examples/gcc/README.md @@ -1,5 +1,8 @@ # Introduction +***TODO: this example should be reworked to use a standalone gcc version, not the one from the +system and readded to Jenkins*** + This directory contains a Makefile and template manifests to run gcc and its related tools on Graphene. We tested with gcc version 5.5.0 and binutils (as, ld) version 2.26.1 on Ubuntu 16.04. We also tested on Ubuntu 18.04 with gcc version 7.4.0 and binutils version 2.30. This example uses the @@ -8,8 +11,6 @@ compiling them from source as some of the other examples do. The Makefile and the template manifest contain comments to hopefully make them easier to understand. -**This example is temporarily broken until we rewrite Graphene loader** - # Quick Start To run the regression tests execute ```make check```. To do the same for SGX, execute ```SGX=1 make diff --git a/Examples/gcc/as.manifest.template b/Examples/gcc/as.manifest.template deleted file mode 100644 index 177a0871..00000000 --- a/Examples/gcc/as.manifest.template +++ /dev/null @@ -1,39 +0,0 @@ -loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" -loader.argv0_override = "as" -loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR):/usr/lib:/usr/$(ARCH_LIBDIR)" -loader.env.PATH = "/" -loader.debug_type = "$(GRAPHENEDEBUG)" - -# Read application arguments directly from the command line. Don't use this on production! -loader.insecure__use_cmdline_argv = 1 - -fs.mount.lib1.type = "chroot" -fs.mount.lib1.path = "/lib" -fs.mount.lib1.uri = "file:$(GRAPHENEDIR)/Runtime" - -fs.mount.lib2.type = "chroot" -fs.mount.lib2.path = "$(ARCH_LIBDIR)" -fs.mount.lib2.uri = "file:$(ARCH_LIBDIR)" - -fs.mount.usr.type = "chroot" -fs.mount.usr.path = "/usr" -fs.mount.usr.uri = "file:/usr" - -fs.mount.tmp.type = "chroot" -fs.mount.tmp.path = "/tmp" -fs.mount.tmp.uri = "file:/tmp" - -sgx.enclave_size = "1G" -sgx.static_address = 1 - -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.libdl = "file:$(GRAPHENEDIR)/Runtime/libdl.so.2" -sgx.trusted_files.libm = "file:$(GRAPHENEDIR)/Runtime/libm.so.6" -sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0" -sgx.trusted_files.libz = "file:$(ARCH_LIBDIR)/libz.so.1" -sgx.trusted_files.libopcodes = "file:/usr/$(ARCH_LIBDIR)/libopcodes-$(BINUTILS_VERSION)-system.so" -sgx.trusted_files.libbfd = "file:/usr/$(ARCH_LIBDIR)/libbfd-$(BINUTILS_VERSION)-system.so" - -sgx.allowed_files.tmp = "file:/tmp" -sgx.allowed_files.test_files = "file:test_files" diff --git a/Examples/gcc/cc1.manifest.template b/Examples/gcc/cc1.manifest.template deleted file mode 100644 index b2893f36..00000000 --- a/Examples/gcc/cc1.manifest.template +++ /dev/null @@ -1,42 +0,0 @@ -loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" -loader.argv0_override = "cc1" -loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR):/usr/lib:/usr/$(ARCH_LIBDIR)" -loader.env.PATH = "/" -loader.env.COMPILER_PATH = "/:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/" -loader.debug_type = "$(GRAPHENEDEBUG)" - -# Read application arguments directly from the command line. Don't use this on production! -loader.insecure__use_cmdline_argv = 1 - -fs.mount.lib1.type = "chroot" -fs.mount.lib1.path = "/lib" -fs.mount.lib1.uri = "file:$(GRAPHENEDIR)/Runtime" - -fs.mount.lib2.type = "chroot" -fs.mount.lib2.path = "$(ARCH_LIBDIR)" -fs.mount.lib2.uri = "file:$(ARCH_LIBDIR)" - -fs.mount.usr.type = "chroot" -fs.mount.usr.path = "/usr" -fs.mount.usr.uri = "file:/usr" - -fs.mount.tmp.type = "chroot" -fs.mount.tmp.path = "/tmp" -fs.mount.tmp.uri = "file:/tmp" - -sgx.enclave_size = "1G" -sgx.static_address = 1 - -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.libdl = "file:$(GRAPHENEDIR)/Runtime/libdl.so.2" -sgx.trusted_files.libm = "file:$(GRAPHENEDIR)/Runtime/libm.so.6" -sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0" - -$(CC1_TRUSTED_LIBS) - -sgx.allowed_files.tmp = "file:/tmp" -sgx.allowed_files.test_files = "file:test_files" -sgx.allowed_files.inc = "file:/usr/include" -sgx.allowed_files.gccinc = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/include" -sgx.allowed_files.gccincfixed = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/include-fixed" diff --git a/Examples/gcc/collect2.manifest.template b/Examples/gcc/collect2.manifest.template deleted file mode 100644 index 68ef3807..00000000 --- a/Examples/gcc/collect2.manifest.template +++ /dev/null @@ -1,41 +0,0 @@ -loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" -loader.argv0_override = "collect2" -loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR):/usr/lib:/usr/$(ARCH_LIBDIR)" -loader.env.PATH = "/" -loader.env.COMPILER_PATH = "/:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/" -loader.debug_type = "$(GRAPHENEDEBUG)" - -# Read application arguments directly from the command line. Don't use this on production! -loader.insecure__use_cmdline_argv = 1 - -fs.mount.lib1.type = "chroot" -fs.mount.lib1.path = "/lib" -fs.mount.lib1.uri = "file:$(GRAPHENEDIR)/Runtime" - -fs.mount.lib2.type = "chroot" -fs.mount.lib2.path = "$(ARCH_LIBDIR)" -fs.mount.lib2.uri = "file:$(ARCH_LIBDIR)" - -fs.mount.usr.type = "chroot" -fs.mount.usr.path = "/usr" -fs.mount.usr.uri = "file:/usr" - -fs.mount.tmp.type = "chroot" -fs.mount.tmp.path = "/tmp" -fs.mount.tmp.uri = "file:/tmp" - -sgx.enclave_size = "1G" -sgx.static_address = 1 - -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.libdl = "file:$(GRAPHENEDIR)/Runtime/libdl.so.2" -sgx.trusted_files.libm = "file:$(GRAPHENEDIR)/Runtime/libm.so.6" -sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0" - -sgx.trusted_files.linker = "file:ld" - -sgx.allowed_files.tmp = "file:/tmp" -sgx.allowed_files.test_files = "file:test_files" - -sgx.trusted_children.linker = "file:ld.sig" diff --git a/Examples/gcc/gcc.manifest.template b/Examples/gcc/gcc.manifest.template index 91b566ee..262bee0e 100644 --- a/Examples/gcc/gcc.manifest.template +++ b/Examples/gcc/gcc.manifest.template @@ -1,9 +1,8 @@ loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" -loader.argv0_override = "gcc" loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR):/usr/lib:/usr/$(ARCH_LIBDIR)" -loader.env.PATH = "/" -loader.env.COMPILER_PATH = "/:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/" +loader.env.PATH = "/bin:/usr/bin" loader.debug_type = "$(GRAPHENEDEBUG)" +libos.entrypoint = "file:/usr/bin/gcc" # Read application arguments directly from the command line. Don't use this on production! loader.insecure__use_cmdline_argv = 1 @@ -25,21 +24,37 @@ fs.mount.tmp.path = "/tmp" fs.mount.tmp.uri = "file:/tmp" sgx.enclave_size = "1G" -sgx.static_address = 1 +sgx.nonpie_binary = 1 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.libdl = "file:$(GRAPHENEDIR)/Runtime/libdl.so.2" sgx.trusted_files.libm = "file:$(GRAPHENEDIR)/Runtime/libm.so.6" sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0" +sgx.trusted_files.libbfd = "file:/usr/$(ARCH_LIBDIR)/libbfd-$(BINUTILS_VERSION)-system.so" -sgx.trusted_files.cc1 = "file:cc1" -sgx.trusted_files.collect2 = "file:collect2" -sgx.trusted_files.as = "file:as" +sgx.trusted_files.liblto = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/liblto_plugin.so" +sgx.trusted_files.libgcc = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/libgcc_s.so" +sgx.trusted_files.libgcca = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/libgcc.a" +sgx.trusted_files.crtend = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/crtend.o" +sgx.trusted_files.crtbegin = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/crtbegin.o" + +sgx.trusted_files.gcc = "file:/usr/bin/gcc" +sgx.trusted_files.cc1 = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/cc1" +sgx.trusted_files.collect2 = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/collect2" +sgx.trusted_files.as = "file:/usr/bin/as" +sgx.trusted_files.ld_ = "file:/usr/bin/ld" sgx.allowed_files.tmp = "file:/tmp" sgx.allowed_files.test_files = "file:test_files" +sgx.allowed_files.aout = "file:a.out" -sgx.trusted_children.cc1 = "file:cc1.sig" -sgx.trusted_children.collect2 = "file:collect2.sig" -sgx.trusted_children.as = "file:as.sig" +sgx.allowed_files.hostdebug = "file:/usr/lib/debug/usr/$(ARCH_LIBDIR)" +sgx.allowed_files.hostusrlib = "file:/usr/$(ARCH_LIBDIR)" +sgx.allowed_files.hostlib = "file:$(ARCH_LIBDIR)" + +sgx.allowed_files.inc = "file:/usr/include" +sgx.allowed_files.gccinc = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/include" +sgx.allowed_files.gccincfixed = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/include-fixed" + +$(LD_TRUSTED_FILES) diff --git a/Examples/gcc/ld.manifest.template b/Examples/gcc/ld.manifest.template deleted file mode 100644 index 14b429fe..00000000 --- a/Examples/gcc/ld.manifest.template +++ /dev/null @@ -1,52 +0,0 @@ -loader.preload = "file:$(GRAPHENEDIR)/Runtime/libsysdb.so" -loader.argv0_override = "ld" -loader.env.LD_LIBRARY_PATH = "/lib:$(ARCH_LIBDIR):/usr/lib:/usr/$(ARCH_LIBDIR)" -loader.env.PATH = "/" -loader.env.COMPILER_PATH = "/:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/" -loader.debug_type = "$(GRAPHENEDEBUG)" - -# Read application arguments directly from the command line. Don't use this on production! -loader.insecure__use_cmdline_argv = 1 - -fs.mount.lib1.type = "chroot" -fs.mount.lib1.path = "/lib" -fs.mount.lib1.uri = "file:$(GRAPHENEDIR)/Runtime" - -fs.mount.lib2.type = "chroot" -fs.mount.lib2.path = "$(ARCH_LIBDIR)" -fs.mount.lib2.uri = "file:$(ARCH_LIBDIR)" - -fs.mount.usr.type = "chroot" -fs.mount.usr.path = "/usr" -fs.mount.usr.uri = "file:/usr" - -fs.mount.tmp.type = "chroot" -fs.mount.tmp.path = "/tmp" -fs.mount.tmp.uri = "file:/tmp" - -sgx.enclave_size = "1G" -sgx.static_address = 1 - -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.libdl = "file:$(GRAPHENEDIR)/Runtime/libdl.so.2" -sgx.trusted_files.libm = "file:$(GRAPHENEDIR)/Runtime/libm.so.6" -sgx.trusted_files.libpthread = "file:$(GRAPHENEDIR)/Runtime/libpthread.so.0" -sgx.trusted_files.libz = "file:$(ARCH_LIBDIR)/libz.so.1" -sgx.trusted_files.libbfd = "file:/usr/$(ARCH_LIBDIR)/libbfd-$(BINUTILS_VERSION)-system.so" - -sgx.trusted_files.liblto = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/liblto_plugin.so" -sgx.trusted_files.libgcc = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/libgcc_s.so" -sgx.trusted_files.libgcca = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/libgcc.a" -sgx.trusted_files.crtend = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/crtend.o" -sgx.trusted_files.crtbegin = "file:$(GCC_LIB_PATH)/$(GCC_MAJOR_VERSION)/crtbegin.o" - -$(LD_TRUSTED_FILES) - -sgx.allowed_files.tmp = "file:/tmp" -sgx.allowed_files.test_files = "file:test_files" -sgx.allowed_files.aout = "file:a.out" - -sgx.allowed_files.hostdebug = "file:/usr/lib/debug/usr/$(ARCH_LIBDIR)" -sgx.allowed_files.hostusrlib = "file:/usr/$(ARCH_LIBDIR)" -sgx.allowed_files.hostlib = "file:$(ARCH_LIBDIR)" diff --git a/Examples/lighttpd/.gitignore b/Examples/lighttpd/.gitignore index b959429c..f587ff6c 100644 --- a/Examples/lighttpd/.gitignore +++ b/Examples/lighttpd/.gitignore @@ -2,7 +2,6 @@ /*.conf /*.tar.gz /install/ -/lighttpd /lighttpd-*/ /lighttpd.conf /OUTPUT diff --git a/Examples/lighttpd/Makefile b/Examples/lighttpd/Makefile index d9f25560..2098c537 100644 --- a/Examples/lighttpd/Makefile +++ b/Examples/lighttpd/Makefile @@ -22,17 +22,12 @@ else GRAPHENEDEBUG = none endif -GREP = grep -SED = sed -LDD = ldd -AWK = awk - CONF_FILES = lighttpd-server.conf lighttpd.conf .PHONY: all -all: $(INSTALL_DIR)/sbin/lighttpd lighttpd.manifest $(CONF_FILES) testdata | lighttpd pal_loader +all: $(INSTALL_DIR)/sbin/lighttpd lighttpd.manifest $(CONF_FILES) testdata | pal_loader ifeq ($(SGX),1) -all: lighttpd.token +all: lighttpd.manifest.sgx lighttpd.sig lighttpd.token endif include ../../Scripts/Makefile.configs @@ -54,61 +49,30 @@ $(LIGHTTPD_SRC)/configure: $(LIGHTTPD_SRC).tar.gz $(LIGHTTPD_SRC).tar.gz: $(GRAPHENEDIR)/Scripts/download --output $@ --sha256 $(LIGHTTPD_HASH) $(foreach mirror,$(LIGHTTPD_MIRRORS),--url $(mirror)/$(LIGHTTPD_SRC).tar.gz) -# lighttpd dependencies (generate from ldd): -# -# For SGX, the manifest needs to list all the libraries loaded during the -# execution, so that the signer can include the file checksums. -# -# The dependencies are generated from the ldd results. +# Generate manifest rules for lighttpd dependencies. +# We'll duplicate some Glibc libraries (which Graphene provides in a customized version), but +# there's no harm in this. +PROGRAMS = $(INSTALL_DIR)/sbin/lighttpd \ + $(INSTALL_DIR)/lib/mod_indexfile.so \ + $(INSTALL_DIR)/lib/mod_dirlisting.so \ + $(INSTALL_DIR)/lib/mod_staticfile.so +.INTERMEDIATE: trusted-libs +trusted-libs: ../common_tools/get_deps.sh $(INSTALL_DIR)/sbin/lighttpd + ../common_tools/get_deps.sh $(PROGRAMS) > $@ -# 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 /lib64/ld-linux-x86-64 libc libm librt libdl libpthread libutil - -LIGHTTPD_LIBS = $(INSTALL_DIR)/lib/mod_indexfile.so \ - $(INSTALL_DIR)/lib/mod_dirlisting.so \ - $(INSTALL_DIR)/lib/mod_staticfile.so - -# Listing all the lighttpd dependencies, besides Glibc libraries -.INTERMEDIATE: lighttpd-deps -lighttpd-deps: $(INSTALL_DIR)/sbin/lighttpd - @$(LDD) $(LIGHTTPD_LIBS) $(INSTALL_DIR)/sbin/lighttpd | \ - $(AWK) '{if ($$2 =="=>") {split($$1,s,/\./); print s[1]}}' | \ - sort | uniq | $($(GREP) -v -x $(patsubst %,-e %,$(GLIBC_DEPS))) > $@ - -# Generating manifest rules for lighttpd dependencies -.INTERMEDIATE: lighttpd-trusted-libs -lighttpd-trusted-libs: lighttpd-deps - @LIGHTTPD_LIBS="$(LIGHTTPD_LIBS)" && \ - for F in `cat lighttpd-deps`; do \ - P=`$(LDD) $$LIGHTTPD_LIBS $(INSTALL_DIR)/sbin/lighttpd | $(GREP) $$F | $(AWK) '{print $$3; exit}'`; \ - N=`echo $$F | tr --delete '-'`; \ - echo -n "sgx.trusted_files.$$N = \\\"file:$$P\\\"\\\\n"; \ - done > $@ - -.INTERMEDIATE: lighttpd-trusted-mods -lighttpd-trusted-mods: - @for F in $(LIGHTTPD_LIBS); do \ - N=`basename $$F .so | tr --delete '-'`; \ - echo -n "sgx.trusted_files.$$N = \\\"file:$$F\\\"\\\\n"; \ - done > $@ - -lighttpd.manifest: lighttpd.manifest.template lighttpd-trusted-libs lighttpd-trusted-mods - @$(SED) -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ - -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ - -e 's|$$(INSTALL_DIR)|'"$(INSTALL_DIR)"'|g' \ - -e 's|$$(INSTALL_DIR_ABSPATH)|'"$(abspath $(INSTALL_DIR))"'|g' \ - -e 's|$$(LIGHTTPD_TRUSTED_MODS)|'"`cat lighttpd-trusted-mods`"'|g' \ - -e 's|$$(LIGHTTPD_TRUSTED_LIBS)|'"`cat lighttpd-trusted-libs`"'|g' \ - -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ - $< > $@ +lighttpd.manifest: lighttpd.manifest.template trusted-libs + (sed -e 's|$$(GRAPHENEDIR)|'"$(GRAPHENEDIR)"'|g' \ + -e 's|$$(GRAPHENEDEBUG)|'"$(GRAPHENEDEBUG)"'|g' \ + -e 's|$$(INSTALL_DIR)|'"$(INSTALL_DIR)"'|g' \ + -e 's|$$(INSTALL_DIR_ABSPATH)|'"$(abspath $(INSTALL_DIR))"'|g' \ + -e 's|$$(ARCH_LIBDIR)|'"$(ARCH_LIBDIR)"'|g' \ + $<; \ + cat trusted-libs) > $@ # Generate the SGX-specific manifest (lighttpd.manifest.sgx), the enclave signature, and the token # for enclave initialization. -lighttpd.manifest.sgx: lighttpd.manifest $(INSTALL_DIR)/sbin/lighttpd | lighttpd +lighttpd.manifest.sgx: lighttpd.manifest $(INSTALL_DIR)/sbin/lighttpd $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-sign \ - -exec lighttpd \ -libpal $(GRAPHENEDIR)/Runtime/libpal-Linux-SGX.so \ -key $(SGX_SIGNER_KEY) \ -manifest lighttpd.manifest -output $@ @@ -118,9 +82,6 @@ lighttpd.sig: lighttpd.manifest.sgx lighttpd.token: lighttpd.sig $(GRAPHENEDIR)/Pal/src/host/Linux-SGX/signer/pal-sgx-get-token -output $@ -sig $^ -lighttpd: $(INSTALL_DIR)/sbin/lighttpd - ln -s $< $@ - pal_loader: ln -s $(GRAPHENEDIR)/Runtime/pal_loader $@ @@ -169,7 +130,7 @@ start-graphene-server: all .PHONY: clean clean: $(RM) *.manifest *.manifest.sgx *.token *.sig pal_loader OUTPUT result-* $(CONF_FILES) \ - lighttpd pal_loader + pal_loader .PHONY: distclean distclean: clean diff --git a/Examples/lighttpd/README.md b/Examples/lighttpd/README.md index 0fee1e95..ea9a7782 100644 --- a/Examples/lighttpd/README.md +++ b/Examples/lighttpd/README.md @@ -37,7 +37,7 @@ Once the server has started, you can test it with `wget` You may also run the benchmark script using `ab` (Apachebench) - ./benchmark-http.sh 127.0.0.1:8003 + ../common_tools/benchmark-http.sh 127.0.0.1:8003 Use Ctrl-C to terminate the server once you are finished testing lighttpd. diff --git a/Examples/lighttpd/benchmark-http.sh b/Examples/lighttpd/benchmark-http.sh deleted file mode 120000 index 38087f85..00000000 --- a/Examples/lighttpd/benchmark-http.sh +++ /dev/null @@ -1 +0,0 @@ -../common_tools/benchmark-http.sh \ No newline at end of file diff --git a/Examples/lighttpd/lighttpd.manifest.template b/Examples/lighttpd/lighttpd.manifest.template index 29428b5c..f84f1241 100644 --- a/Examples/lighttpd/lighttpd.manifest.template +++ b/Examples/lighttpd/lighttpd.manifest.template @@ -6,7 +6,7 @@ # # ./pal_loader ./lighttpd