Commit Graph

1217 Commits

Author SHA1 Message Date
Tate, Hongliang Tian
663f548f94 Workaround exit_group syscall
BACKGROUND

The exit_group syscall, which is implicitly called by libc after the main function
returns, kills all threads in a thread group, even if these threads are
running, sleeping, or waiting on a futex.

PROBLEM

In normal use cases, exit_group does nothing since a well-written program
should terminate all threads before the main function returns. But when this is
not the case, exit_group can clean up the mess.

Currently, Occlum does not implement exit_group. And the Occlum PAL process
waits for all tasks (i.e., SGX threads) to finish before exiting. So without
exit_group implemented, some tasks may be still running if after the main task
exits. And this causes the Occlum PAL process to wait---forever.

WORKAROUND

To implement a real exit_group, we need signals to kill threads. But we do not
have signals, yet. So we come up with a workaround: instead of waiting all
tasks to finish in PAL, we just wait for the main task. As soon as the main
task exits, the PAL process terminates, killing the remaining tasks.
2019-11-07 13:34:53 +00:00
Tate, Hongliang Tian
30c99add6f Add nanosleep syscall 2019-11-07 13:24:02 +00:00
Tate, Hongliang Tian
c8a921fd4b Refactor program loader to handle many loadable segments
The original implementation of program loader is written under the assumption
that there are only two loadable segments per ELF, one is code, and the other
is data. But this assumption is unnecessary and proves to be wrong for an ELF
on Alpine Linux, which has two extra read-only, loadable segments for security
hardening. This commit clears the obstacle towards running unmodified
executables from Alpine Linux.

In addition to getting rid of  the false assumption of two fixed loadable segments,
this commit improves the quality of the code related to program loading and
process initialization.
2019-11-07 13:19:09 +00:00
Zhengde Zhai
1a56fc4b72 Check program paths against entry points in Occlum.json 2019-11-07 02:42:59 +00:00
Tate, Hongliang Tian
4cb63a4d99 Fix a mistaken assert for debug build 2019-10-21 08:34:27 +00:00
Tate, Hongliang Tian
8f3ff6d866 Fix minor bugs in Dockerfile 2019-10-19 06:03:50 +00:00
Tate, Hongliang Tian
f9376ec4ba Polish the demos
1. Rename demo/ to demos/
2. Add demos/README.md
2019-10-19 02:04:13 +00:00
Tate, Hongliang Tian
6dc9906c8e Preinstall Occlum in Docker 2019-10-18 13:40:09 +00:00
Tate, Hongliang Tian
ebd3608e4a Start up AESM service automatically in Docker 2019-10-18 13:40:09 +00:00
LI Qing
ba6b4cc028 Add HTTPS file server Demo
The demo shows how to run the unmodified HTTPS file server with Occlum.
2019-10-18 13:32:05 +00:00
LI Qing
5f26bfc1fb Add C/C++ Hello World with Makefile, CMake, and Bazel 2019-10-18 12:54:07 +00:00
LI Qing
ba7db98e49 Add Tensorflow Lite Demo
The demo shows how to run the unmodified Tensorflow Lite on Occlum.
2019-10-14 08:55:45 +00:00
He Sun
24116c426f Fix address-in-use error in server and server_epoll tests 2019-10-14 14:33:27 +08:00
Tate, Hongliang Tian
1a365de08f Introduce the new error handling mechanism
* Fast error diagnosing (e.g., backtrace and code location)
* First-class POSIX errno (e.g., every error has an errno)
* Zero-overhead abstraction (e.g., no heap allocation for simple errors)
* Ergonomic grammar (e.g., providing convenient macros)
2019-10-14 03:50:20 +00:00
LI Qing
d8d51fcfd4 Support running enclaves in SGX release mode.
* 'occlum init' does not copy signing key file any more.
* 'occlum build' supports to set signing key and signing tool in args.
* 'occlum run' supports to run enclave in sgx release mode.
2019-10-12 17:16:06 +00:00
Shuang Liu
68e02962d5 Harden SEFS with extra MAC and permission checks 2019-10-12 16:55:57 +00:00
Tate, Hongliang Tian
70fd9dc210 Fix the broken backtrace info on panic 2019-10-08 03:44:04 +00:00
Tate, Hongliang Tian
ae46caa63a Fix the permissions of user-editable config files 2019-10-08 03:42:50 +00:00
He Sun
dba6467c2d Fix server_epoll test
1. Change the port for server_poll to listen to avoid "address in use" conflict
between test/server and test/server_epoll, and add port as an argument for
test/client to send message
2. As posix-spwan may fail, change the fixed number of processes to spawn to
the number of processes successfully spawned in server_epoll
2019-10-07 04:36:12 +00:00
Tate, Hongliang Tian
f414aa3eec Fix typos in README.md 2019-09-23 15:44:04 +00:00
Tate, Hongliang Tian
f04c33aae2 Update README for version 0.5.0 2019-09-07 07:35:37 +00:00
Tate, Hongliang Tian
6aa49d867a Update copyright information in LICENSE 2019-09-06 15:37:45 +00:00
Shuang Liu
d61edad08f Randomize the file names of SEFS inodes on the host FS 2019-09-06 15:08:13 +00:00
Tate, Hongliang Tian
00949d9741 Introduce GCC-base toolchain and use it by default 2019-09-06 13:02:45 +00:00
LI Qing
8ef52c7c2d Support environmental variables in Occlum.json
1. Now we support set App's env in Occlum.json, for example:
    "env": [
        "OCCLUM=yes",
        "TEST=true"
    ]
2. Rewrite env test cases
3. Update Dockerfile to install "jq" tool
2019-09-05 13:50:55 +00:00
LI Qing
f37eb34038 Rewrite cpuid and rdtsc exception handlers
1. Rewrite cpuid and rdtsc exception handle in Rust
2. Rewrite cpuid test cases
3. Update Dockerfile to install cpuid tool for test
2019-09-05 13:50:34 +00:00
Tate, Hongliang Tian
ba78f09d1c Add Hello World demo 2019-08-31 06:39:33 +00:00
Tate, Hongliang Tian
347791f235 Add install target for Makefile 2019-08-31 06:01:16 +00:00
Tate, Hongliang Tian
5c5b0ea429 Add Git hooks that check Rust code format issues 2019-08-28 06:32:50 +00:00
Tate, Hongliang Tian
d77c21f98c Add a command-line interface tool named occlum
1. All generated, build files are now in a separate build directory;
2. The CLI tool supports three sub-commands: init, build, and run;
3. Refactor tests to use the new tool.
2019-08-28 06:05:12 +00:00
Tate, Hongliang Tian
7001b32a4a Format all Rust code with cargo fmt
In addition, to ensure that all future Rust code complies with
`cargo fmt`, we add a Git post-commit hook that generates warnings
if the commited code is not formated consistently.
2019-08-17 07:38:16 +00:00
Tate, Hongliang Tian
dff0dbf77d Add the integrity-only mode SEFS
* Add patch to Rust SGX SDK to enable integrity-only SgxFile
* Upgrade to the new SEFS extended with the integrity-only mode
* Use integrity-only SEFS for /bin and /lib in test
* Add the MAC of integrity-only SEFS to Occlum.json in test
* Mount multiple FS according to Occlum.json
* Check the MACs of integrity-only SEFS images
2019-08-17 04:20:11 +00:00
Tate, Hongliang Tian
76f91a1aa3 Add Occlum.json. No more configs hardcoded in code
1. Add Occlum.json as Occlum's config file
2. Add tools/bin/build_enclave
3. Add tools/bin/protect_integrity
4. Validate Occlum.json.protected on LibOS startup
5. Parse Occlum.json.protected on LibOS startup
6. Config enclave size using Occlum.json
7. Config process memory sizes using Occlum.json
2019-08-09 09:19:51 +00:00
LI Qing
cff0de1c39 Add sched_xetaffinity() system calls in Occlum
1. LibOS support sched_getaffinity() and sched_setaffinity() system calls
2. Add sched_cpu_affinity test cases in occlum/test/sched
2019-08-05 15:22:20 +08:00
Tate, Hongliang Tian
03c19ae2c6 Update AESM path in README 2019-08-02 08:48:10 +00:00
Wang Runji
c656776eb1 Fix MountFS sync 2019-08-02 08:34:40 +00:00
Wang Runji
c68c3c9a94 Fix the write-without-updating-size bug of SEFS 2019-08-02 05:31:42 +00:00
Tate, Hongliang Tian
a2169e63e8 Upgrade Dockerfile for dynamic-linking support 2019-08-01 12:23:37 +00:00
Tate, Hongliang Tian
e11c30c5c5 Run dynamically-linked hello world 2019-07-20 03:34:00 +00:00
Tate, Hongliang Tian
33739cc00b Program loader loads ld.so now 2019-07-20 03:34:00 +00:00
Tate, Hongliang Tian
13974315ad Fix all compiler warnings for tests 2019-07-20 03:34:00 +00:00
Tate, Hongliang Tian
a579f84e90 Enable new system call mechanism via Auxiliary Vector
The old system call mechanism works by relocating the symbol __occlum_syscall
provided by libocclum_stub.so to the real entry point of the LibOS. This symbol
relocation is done by the program loader. Now, the new system call mechanism is
based on passing the entry point via the auxiliary vector. This new mechanism
is simpler and is more compatible with the upcoming support for ld.so.

Changes:
1. Fix a bug in serializing auxiliary vector in the stack of a user program;
2. Passing syscall entry via auxiliary vector;
3. Remove relocating for the __occlum_syscall symbol;
4. Remove the dependency on libocclum_stub.so in tests.
2019-07-20 03:34:00 +00:00
geding.lq
9c226c9a9f Fix a bug in cpuid, which mistakenly use %rax where %eax is actually needed 2019-07-20 03:23:50 +00:00
Tate, Hongliang Tian
8686322afb Add /dev/zero, /dev/random, /dev/urandom, and /dev/arandom 2019-07-19 12:30:15 +00:00
Tate, Hongliang Tian
8cda63ab3a Use SEFS at /, HostFS at /host, and RamFS at /tmp 2019-07-19 10:25:33 +00:00
Wang Runji
7f229cef50 add simple HostFS, mount it at /host 2019-07-19 03:51:38 +00:00
Wang Runji
29278db8f4 support multiple fs
- use RamFS as rootfs, mount SEFS at /test
- for testing convenience, set default cwd to /test
- fix spawn path and change_cwd
2019-07-19 03:49:18 +00:00
Tate, Hongliang Tian
30265261cf Remove a deprecated submodule sgx_protect_file 2019-07-18 11:02:01 +00:00
Tate, Hongliang Tian
e1e46c9935 Add clock_gettimeofday 2019-07-18 10:51:12 +00:00
Tate, Hongliang Tian
c096e7d0b9 Inform Intel SGX SDK about Occlum-defined stacks
There are two types of stacks: the kernel ones and the user ones. The kernel
stacks are used by Occlum and managed by Intel SGX SDK itself, while the user
stacks are used by the threads created and managed by Occlum. These user stacks
are transparent to Intel SGX SDK so far.

The problem is that Intel SGX SDK needs to be aware of the user stacks.
SGX exception handlers will check whether the rsp value---when the exception
happened---is within the stack of the current SGX thread. If the check fails,
the registered exception handler will not be triggered. But when exceptions are
triggered by the threads running upon Occlum, the rsp value points to the user
stacks, which Intel SGX SDK are completely unware of. So the check always
fails.

Therefore, we extend Intel SGX SDK with two new APIs:

  int sgx_enable_user_stack(size_t stack_base, size_t stack_limit);
  void sgx_disable_user_stack(void);

And this commit uses the two APIs to inform Intel SGX SDK about the
Occlum-managed stacks. And the rsp checks in SGX exception handlers will
check whether rsp is within the user stacks.
2019-07-18 07:16:17 +00:00