359 Commits
Author SHA1 Message Date
Chia-Che Tsai 6c4f21cba2 [Pal/Linux-SGX] Simple remote attestation framework
This is the minimalistic implementation of the remote attestation
framework. The framework conducts the following steps during
start-up to verify the authenticity of the SGX platform:

1. Connect to aesmd service to retrieve platform info (targetinfo)
   of the Quoting Enclave (QE) before enclave creation.
2. Prepare the SGX report inside enclave (during initialization):
   - Read SPID (service provider ID) from sgx.ra_client_spid in
     manifest.
   - Get an SGX report for local attestation to QE.
   - Generate a random 16-byte nonce for freshness.
   - Perform an OCALL for retrieving the quote.
3. Gather attestation data (QE report, QE quote, IAS report, signature,
   certificate chain) outside of enclave:
   - Connect to aesmd to retrieve the QE quote; aesmd also returns
     QE report.
   - Connect to Intel Attestation Service using curl. A client
     subscription key (specified via sgx.ra_client_key in manifest)
     is required to authenticate the HTTPS connection.
   - Get the IAS report, signature, and certificate chain from IAS.
     Print out the attestation result.
   - Return all this attestation data back to the enclave.
2019-09-10 21:00:49 -07:00
Chia-Che Tsai 99ec09b2be [Pal/Skeleton] Fix the build of Skeleton PAL 2019-09-10 14:55:25 -07:00
Chia-Che Tsai 2e13503624 [Pal/Linux-SGX] Reimplement local attestation for process creation 2019-09-10 15:04:18 +02:00
Michał Kowalczyk de42ebabe1 Reformat repository to our clang-format rules 2019-09-09 22:11:23 +02:00
Michał Kowalczyk 6356559e39 Fix header dependencies 2019-09-09 22:11:23 +02:00
borysp 62ecb4bc79 [Makefile] Prevent gcc from generating trampolines 2019-09-04 03:10:33 +02:00
borysp f31c4071af [Pal/SGX] Add a helpful debug message when enclave attestation fails 2019-09-04 00:09:26 +02:00
Don Porter 6a0ce55b7c [Pal/Linux-SGX/sgx-driver] Ignore *.o.ur-safe files 2019-09-03 23:19:30 +02:00
Isaku Yamahata 723af03513 [Pal] Makefile.Host: define/export SYS if it's not defined
Makefile.Host can be called with PAL_HOST defined but SYS undefined.
Also export SYS.
2019-08-24 01:50:45 +02:00
Isaku Yamahata d887ef39f4 [Pal/Linux] Remove unused Makefile.test
Makefile.Test is used, not Makefile.test.
2019-08-21 14:37:13 +02:00
Isaku Yamahata 9af27a82b0 [Makefile, Pal/Linux-SGX] Calculate dependencies for *.manifest.sgx 2019-08-21 14:37:13 +02:00
Isaku Yamahata 9d3344b808 [Pal/Linux-SGX] Set CLOEXEC on /dev/isgx and /dev/gsgx
On host exec, file descriptors for /dev/isgx and /dev/gsgx are leaked.
Set CLOEXEC for them to be closed when emulating fork/exec by using host
exec.
2019-08-20 21:29:15 +02:00
Don Porter 60bed726e3 [PAL] Fix cpuid parsing on a system with hyperthreads 2019-08-19 16:13:42 -04:00
Li Lei 30e0b8bfba [PAL/Linux-SGX] Reuse TLS/TCS pages for newly created threads after previous threads exit 2019-08-16 18:17:24 -07:00
Isaku Yamahata 215c00ab0c [Pal/Linux-SGX] Makefile cleanup 2019-08-16 16:58:57 -07:00
Simon Gaiser 517be2a241 [LibOS,Pal] Improve recursive Make calls
Do not declare the result of the recursive Make call as "phony" to avoid
unnecessary rebuilds. Due to the missing dependency information we of
course still need to always recurse.
2019-08-14 00:44:17 +02:00
Simon Gaiser 64e46adcc0 [Makefile] Use generated header dependencies
Fixes #189.
2019-08-14 00:44:17 +02:00
Simon Gaiser 1ff85d10a3 [Makefile] Move building of tests to a separate target
Fixes #204.
2019-08-14 00:44:17 +02:00
borysp cbac2b5b50 [Pal] Fix typos 2019-08-13 16:18:35 +02:00
borysp d4ac504842 [Pal] Enable relative manifest path 2019-08-12 20:22:27 -07:00
borysp 7df0739e9a [Pal] Fix bugs in path normalization
Previous implementation had a few bugs in path-normalization functions,
e.g., in get_norm_path(): "../..a/" -> "....a" and "/../a"   -> "../a",
and in get_base_name(): "/" -> garbage (buffer overflow).
2019-08-12 20:21:19 -07:00
Chia-Che Tsai f2591790d7 [LibOS] Fix timeout resolution for epoll_wait()/epoll_pwait()
Internal LibOS and PAL interfaces use microseconds (us) for timeout
values. However, Linux epoll_wait/epoll_pwait syscalls use milliseconds
(ms) for timeout. Previously, there was a bug in timeout resolution
because epoll_wait() emulation did not convert from ms to us. This
commit fixes this bug and also adds suffixes "_ms" and "_us" to make the
time units used explicit.
2019-08-08 17:37:39 -07:00
Isaku Yamahata 77904ffeb0 [Pal/Linux-SGX] Fix incorrect "0x%p" format string for ocall_load_debug()
Previously, setup_pal_map() instructed GDB to load symbols for the PAL
shared library using incorrectly formatted string with "0x%p". This led
to addresses of the form "0x0xdeadbeef" which could not be parsed by
GDB. This commit fixes this via "%p" and thus enables SGX-GDB again.
2019-08-07 16:22:00 -07:00
Isaku Yamahata 161ea54354 [pal_loader] Introduce INSIDE_EMACS arg to pal_loader so it runs GDB under Emacs 2019-08-05 12:22:27 -07:00
Isaku Yamahata f53c3afd95 [Pal/Linux-SGX] Fix undef behavior by initializing opt with const in get_sockopt() 2019-08-02 17:35:13 -07:00
borysp 56f93d3a9f [Pal/Linux-SGX] Fix allowed_files subdirectory check
If the path of allowed directory in a manifest file ended with a '/'
e.g. "sgx.allowed_files.tmp_dir = file:tmp/" anything inside it was
disallowed due to a buggy subdirectory check
2019-08-02 22:05:12 +02:00
Martin Schmatz b6d327edac [Pal/Linux-SGX] Initialize socket options to zero and reuseaddr to 1
This commit fixes uninitialized variable sock_options in tcp_connect(),
tcp_listen(), tcp_accept(), udp_bind(), and udp_connect().
2019-08-02 03:28:45 -07:00
Michał Kowalczyk 70b8b27f94 [PAL/Linux-SGX/gsgx] Fix up compatibility with isgx 1.9 2019-08-02 01:47:00 +02:00
Michał Kowalczyk 5ec5e2f24c Delete all reference monitor residues 2019-07-31 02:30:47 +02:00
Isaku Yamahata 711c9935f4 [Pal/{Linux, Linux-SGX}] Introduce PAL_TCB as a common structure
Introduce PAL_TCB common structure for Linux and Linux-SGX PALs such
that LibOS can stash its tcb into PAL_TCB. This commit is a preparation
for statically-linked binary support where the LibOS tcb can be embedded
into per-application-thread structure.

Additionally, SHIM_TCB_USE_GS is introduced as a compile-time option to
enable/disable this feature.
2019-07-30 18:00:31 -07:00
Isaku Yamahata 747226cbe0 [Pal/{Linux,Linux-SGX}] Remove unused dev_attrcopy()
The static function, dev_attrcopy() in db_devices.c is unused.
Remove it.
2019-07-30 21:59:44 +02:00
Chia-Che Tsai 429aee3527 [PAL] Clean up reference monitor residues 2019-07-30 19:47:49 +02:00
Chia-Che Tsai ad0dd8be31 [PAL] Purge the reference monitor loader code (move to EXPERIMENTAL)
This commit removes the following from the master Graphene branch (this
is now moved to the EXPERIMENTAL/linux-reference-monitor branch):
- Remove reference monitor loader code
- Remove sandboxing code and dependency to reference monitor code
- Remove Linux kernel changes for reference monitor
- Remove README instructions and scripts regarding reference monitor
2019-07-26 15:32:49 -07:00
borysp 92f135ab86 [Pal/{Linux,Linux-SGX}] Fix Pal/host dir_read bugs
dir_read() never updated handle->dir.ptr and handle->dir.end which
effectively disallowed multipart responses. This commit rewrites
this function to handle multiple reads from one handle and also
use less memory.
2019-07-24 12:36:14 -07:00
Michał Kowalczyk 52786e5f4d Fix a bunch of typos 2019-07-23 15:03:52 -07:00
Isaku Yamahata f0753437f5 [LibOS/Pal] Convert remaining python2 scripts to python3 2019-07-23 12:13:21 -07:00
Alex Merritt 95fce86545 [Pal/Linux-SGX] Fix typo DEAFULT* to DEFAULT* 2019-07-23 02:09:43 -07:00
Isaku Yamahata 9a37c5cc36 [Pal/Linux-SGX] Force ocall_gettime() to loop on EINTR
SGX PAL-level functions like _DkSystemTimeQuery() assume that
ocall_gettime() does not return EINTR. Thus, this commit forces
this ocall to loop on EINTR.
2019-07-20 16:27:55 -07:00
Isaku Yamahata a26fa5e958 [Pal/Linux-SGX] Refactor get_reserved_pages() 2019-07-20 14:35:24 -07:00
Isaku Yamahata 29fdd5fe1e [Pal/{Linux,Linux-SGX}] Block async signals during vfork
To avoid vfork child from corrupting parent's memory, block async
signal before vfork(). Children unblock async signal after execve in
{sgx_}signal_setup().
2019-07-19 16:56:47 +02:00
Dmitrii Kuvaiskii b5465d7b57 [Pal/Linux-SGX] Distinguish between DkProcessExit() and DkThreadExit()
Previously, both DkProcessExit() and DkThreadExit() used SGX OCALL
ocall_exit(exitcode), which finally issued exit() syscall. This is
incorrect because DkProcessExit() must exit the whole process and not
just a single thread. This led to abandoned IPC/Async helper threads
in some Graphene-SGX corner cases. This commit forces DkProcessExit()
to result in exit_group() syscall, achieved by adding a new argument
to ocall_exit(exitcode, is_exitgroup).
2019-07-19 01:03:41 -07:00
Isaku Yamahata 427051bc97 [Pal/Linux-SGX] Remove deadcode in sgx_graphene.c: _DkEventSet & _DkEventWait 2019-07-18 15:55:51 -07:00
Isaku Yamahata 8a45977484 [Pal/Linux-SGX] Return -ERRNO instead of -PAL_ERROR_XXX in OCALLs
OCALL functions should return -ERRNO on errors:
- on signals/interrupts, return -EINTR instead of -PAL_ERROR_INTERRUPTED;
- on host-OS syscalls, return -ERRNO(ret) instead of -PAL_ERROR_DENIED;
- on no-available-threads, return -EINVAL instead of -PAL_ERROR_INVAL.
2019-07-18 15:55:51 -07:00
Isaku Yamahata 13944f506a [Pal/Linux] Use dedicate stack for vfork() child
With vfork(), parent and child share the same stack. The child must not
modify the parent's stack frame (otherwise parent's local variables are
corrupted). To circumvent this, this commit introduces a dedicated noinline
function to have a stack frame local to the child. (This bug was hit on
GCC 8 which reuses the same stack location for local variables with disjoint
lifetimes.)
2019-07-15 20:44:09 -07:00
Isaku Yamahata 4077c5a816 [Pal/Linux-SGX] Use dedicate stack for vfork() child
With vfork(), parent and child share the same stack. The child must not
modify the parent's stack frame (otherwise parent's local variables are
corrupted). To circumvent this, this commit introduces a dedicated noinline
function to have a stack frame local to the child. (This bug was hit on
GCC 8 which reuses the same stack location for local variables with disjoint
lifetimes.)
2019-07-15 20:44:09 -07:00
Isaku Yamahata 70050a5fa3 [Pal/Linux-SGX] Remove duplicated reg clearing on sgx_ocall
%rdx, %rbp, %r8-%r15 are cleared twice unnecessarily on sgx_ocall.
2019-07-16 00:41:11 +02:00
Simon Gaiser 7276bb9d78 [Pal/Linux-SGX] Correctly clear registers in enclave_entry.S
Tiny bug fixes in enclave_entry.S to clear registers:
- Do not clear %r11 twice before EEXIT
- Simulate CLD (by manually clearing DF flag stored in SGX_GPR_RFLAGS)
  on interrupt just after EENTER returning from ocall
- Simulate CLD (by manually clearing DF flag stored in SGX_GPR_RFLAGS)
  on preparation for exception handler _DkExceptionHandler()
2019-07-15 12:28:28 -07:00
Isaku Yamahata 204938ee35 [Makefiles] Drop %.e target
Commonly %.i or %.s is used for preprocessed files, not %.e. Drop it in
preference to %.i and %.s.
2019-07-11 07:04:33 +02:00
Isaku Yamahata 0e2384c747 [Makefiles] Drop %.asm rule
%.asm is not widely used in unix world and the rule seems hacky.
So drop %.asm rule.
2019-07-11 07:04:33 +02:00
Isaku Yamahata 4789a3a188 [{shim,Pal}] Refactor Makefiles to utilize Makefile.rules 2019-07-11 07:04:33 +02:00