Commit Graph

355 Commits

Author SHA1 Message Date
Hui, Chunyang
dadffb9f17 Fix sendfile syscall write buffer length 2020-05-21 17:20:12 +08:00
Hui, Chunyang
c6e0e06768 Clean up the build files generated in src/exec 2020-05-21 08:54:42 +00:00
Zongmin
17b4912055 Send SIGCHLD to parent process 2020-05-18 20:24:14 +08:00
Tate, Hongliang Tian
e1789dc89f Bump version to 0.12.0
Also, update the docs accordingly.
2020-05-15 11:32:44 +00:00
He Sun
9252a1a993 Fix two bugs of ioctl
1. Add length of the argument to the ioctl ocall to guard sgx sdk to do
the copy.
2. Handle non-zero return value of ioctl.
2020-05-15 12:50:31 +08:00
Zongmin
0c3466f4ad Add three new occlum commands: start, exec and stop
Usage:
//start the occlum server
occlum start

//execute the command inside occlum
occlum exec [cmd] [-- <args>]

//stop the occlum server
occlum stop
2020-05-15 03:02:42 +00:00
LI Qing
2d34ee349e Add the sigaltstack system call 2020-05-15 03:02:42 +00:00
Hui, Chunyang
0bb1cbfbb5 Add PAL version api 2020-05-15 03:02:42 +00:00
He Sun
f9486bf7a9 Add resource limit check for the number of the fds in poll 2020-05-15 03:02:42 +00:00
zongmin.gu
eca27408be Support user manage stack
Go/Java/JIT code manage their own stack
So we need to help them to handle exception
2020-05-15 03:02:42 +00:00
Zongmin
a6d97d5b4f Update the sdk version to 2.9.1
Fix std::alloc::Alloc not found
The lastest Rust changes the trait to std::alloc::AllocRef.

Update the docker files to support sgx 2.9.1

Remove the compilerRT dependency for rust sdk update
2020-05-15 03:02:42 +00:00
Tate, Hongliang Tian
1d1330772c Add new API occlum_pal_kill
This API enables sending signals to one or multiple LibOS processes from
outside the enclave.
2020-05-15 03:02:42 +00:00
Tate, Hongliang Tian
6e140a0d38 Add errno info for ECalls
Before this commit, the three ECalls of the LibOS enclave do not give
the exact reason on error. In this commit, we modify the enclave entry code
to return the errno and list all possible values of errno in Enclave.edl.
2020-05-15 02:59:16 +00:00
He Sun
1c707eda30 Add support for monitoring epoll fds with epoll 2020-05-15 02:59:16 +00:00
Hui, Chunyang
25350b0e85 Fix sched agent failure for offline core 2020-05-15 02:59:16 +00:00
He Sun
7a87d77509 Fix error when PF_UNIX is passed as protocol to create unix socket
Zero and PF_UNIX are both supported as protocol when creating unix
socket.
2020-05-15 02:59:16 +00:00
Tate, Hongliang Tian
e166382923 Add the signal subsystem
In this commit, we add eight signal-related syscalls
* kill
* tkill
* tgkill
* rt_sigaction
* rt_sigreturn
* rt_sigprocmask
* rt_sigpending
* exit_group

We implement the following major features for signals:
* Generate, mask, and deliver signals
* Support user-defined signal handlers
    * Support nested invocation of signal handlers
    * Support passing arguments: signum, sigaction, and ucontext
* Support both process-directed and thread-directed signals
* Capture hardware exceptions and convert them to signals
* Deliver fatal signals (like SIGKILL) to kill processes gracefully

But we still have gaps, including but not limited to the points below:
* Convert #PF (page fault) and #GP (general protection) exceptions to signals
* Force delivery of signals via interrupt
* Support simulation mode
2020-05-15 02:59:16 +00:00
LI Qing
1172c25677 Modify occlum_entry to be compatible with Linux syscall ABI 2020-05-15 02:59:16 +00:00
Hui, Chunyang
72f2a33e2a Add log level alignment with OCI 2020-05-15 02:59:16 +00:00
He Sun
71475c3e96 Fix wrong assert in recvmsg for MSG_TRUNC flag 2020-05-15 02:59:16 +00:00
He Sun
bbb52f6990 Refine check for pointers from user space and outside enclave
Implement the check functions that are empty before and do some
adjustment where they are called.
2020-05-15 02:59:16 +00:00
LI Qing
1dcabb09cd Fix the access and faccessat system calls 2020-05-15 02:59:16 +00:00
LI Qing
6d27595195 Fix the negative offset check for pread/pwrite 2020-05-15 02:59:16 +00:00
He Sun
48d7f8df3e Fix the invalid epoll_event pointer introduced by compilation optimization
That pointer does not point to the libc::epoll_event after release
build. Explicitly declaring the libc::epoll_event avoids the
invalidation.
2020-05-15 02:59:16 +00:00
Hui, Chunyang
6a17e6292c Add support for user specified instance dir name
The default instance dir of Occlum is ".occlum". User now can specify the name
by declaring environment variable "OCCLUM_INSTANCE_DIR"
2020-05-15 02:59:16 +00:00
LI Qing
03bb09abdf Add the emulation of SYSCALL instruction
1. Refactor the exception handling process
2. Support to emulate the SYSCALL instruction in the exception handler
2020-05-15 02:59:16 +00:00
Hui, Chunyang
79fd6570f5 Change log level to warning for ioctl TIOCGWINSZ 2020-05-15 02:59:16 +00:00
He Sun
aa10d96f89 Fix u32::MAX not found error
Using std::u32 instead of u32 passes the compilation.
2020-05-15 02:59:16 +00:00
He Sun
e651be4403 Fix not passing null pointers to ocalls for empty slices
It gets a non-null fat pointer when an empty slice simply calls as_ptr
or as_mut_ptr.
2020-05-15 02:59:16 +00:00
He Sun
58403f8415 Fix panic when dropping unix socket
When a unix socket only calls function listen, its object is not created
but its status becomes listening. At this time closing the socket would
cause a panic before this commit.
2020-05-15 02:59:16 +00:00
He Sun
9815523a95 Fix panic when there is no enough memory for a new ringbuffer 2020-05-15 02:59:16 +00:00
Hui, Chunyang
53f8ade4de Fix a typo 2020-05-15 02:59:16 +00:00
yuanwu
ed7f83562a Check the MPX status of platform before enabling
Signed-off-by: yuanwu <yuan.wu@intel.com>
2020-04-26 15:02:26 +08:00
Tate, Hongliang Tian
5b4b72a81a Bump the version number to 0.11.0 2020-04-17 17:52:17 +08:00
Tate, Hongliang Tian
ad077d644a Fix the demo for the embedded mode 2020-04-16 08:46:56 +00:00
Tate, Hongliang Tian
df71872f76 Disable Intel MPX by default
The next generation of Intel CPUs does not support Intel MPX. Enabling MPX
by default crashes the LibOS on startup. So we disable MPX by default. The
long term plan is to turn on/off MPX via compiling options.
2020-04-15 21:25:24 +08:00
Tate, Hongliang Tian
2b556f8de9 Refactor the CPU scheduling subsystem
This commits improves both readability and correctness of the scheduling-related
system calls. In terms of readability, it extracts all scheduling-related code
ouf of the process/ directory and put it in a sched/ directory. In terms
of correctness, the new scheduling subsystem introduces CpuSet and SchedAgent
types to maintain and manipulate CPU scheduler settings in a secure and robust way.
2020-04-15 09:43:38 +00:00
Tate, Hongliang Tian
2a1d3d98c5 Refactor the process/thread subsystem
As a major rewrite to the process/thread subsystem, this commits:
1. Implements threads as a first-class object, which represents a group of OS resources
and a thread of execution;
2. Implements processes as a first-class object that manages threads and maintains
the parent-child relationship between processes;
3. Refactors the code in process subsystem to follow the improved coding style and
conventions emerged in recent commits;
4. Refactors the code in other subsystems to use the new process/thread subsystem.
2020-04-15 06:22:41 +00:00
LI Qing
bbc3b8a467 Fix RDTSC emulation's changing app's TLS by mistake
This commit switches from user mode to kernel mode before handling
the exception caused by RDTSC instruction.
2020-04-10 09:53:39 +00:00
He Sun
52cb897436 Fix F_DUPFD crash when there is no space in file table 2020-04-03 12:47:04 +08:00
LI Qing
978edf8a17 Add chmod and chown system calls 2020-04-03 03:39:57 +00:00
LI Qing
e1648fc870 Add the redirection of standard I/O for process 2020-04-02 11:07:24 +00:00
He Sun
221f5b78e8 Rewrite epoll implementation and the test 2020-04-02 17:43:24 +08:00
Tate, Hongliang Tian
a7400ca6dc Fix thread exiting but not being freed 2020-03-31 14:47:31 +00:00
LI Qing
23329efe14 Fix the broken dependency on SEFS
SEFS depends on version 0.9 of bitvec crate, which has been yanked on crates.io
by the crate author for some reasons. To fix this, we upgrade to the latest
version of bitvec crate.
2020-03-30 08:58:57 +00:00
Tate, Hongliang Tian
1eefa0a123 Fix poll when given negative fds 2020-03-27 18:00:49 +08:00
Tate, Hongliang Tian
6dbdbfdcf0 Fix potential deadlocks caused by epoll/poll/select 2020-03-27 05:42:20 +00:00
Tate, Hongliang Tian
1a35188212 Simplify the frequent code of getting a file reference 2020-03-26 10:34:14 +00:00
Tate, Hongliang Tian
5933499f9b Refactor LibOS to conform with logging strategy
This commit introduces a unified logging strategy, summarized as below:

1. Use `error!` to mark errors or unexpected conditions, e.g., a
 `Result::Err` returned from a system call.
2. Use `warn!` to warn about potentially problematic issues, e.g.,
 executing a workaround or fake implementation.
3. Use `info!` to show important events (from users' perspective) in
 normal execution, e.g., creating/exiting a process/thread.
4. Use `debug!` to track major events in normal execution, e.g., the
 high-level arguments of a system call.
5. Use `trace!` to record the most detailed info, e.g., when a system
 call enters and exits the LibOS.
2020-03-25 02:53:31 +00:00
Tate, Hongliang Tian
9713e74ed9 Add the support for setting log level at runtime
Now one can specify the log level of the LibOS by setting `OCCLUM_LOG_LEVEL`
environment variable. The possible values are "off", "error", "warn",
"info", and "trace".

However, for the sake of security, the log level of a release enclave
(DisableDebug = 1 in Enclave.xml) is always "off" (i.e., no log) regardless of
the log level specified by the untrusted environment.
2020-03-25 01:40:47 +00:00
Tate, Hongliang Tian
6d7cf7b9f6 Add more info to log messages (e.g., timestamp, thread, and round) 2020-03-25 01:34:41 +00:00
Tate, Hongliang Tian
dddcb89f7e Refactor the LibOS entry point by introducing system call table
This commit introduces a system call table, which brings several benefits:

1. The table is a centralized info hub that one can find an answer for every
question about system calls, e.g., what is the number and arguments of a
system call, is it implemented or supported, and if so, what is the
function that actual implements it.

2. System call-related code can be automatically derived from the system call
table through a clever use of macros. In this way, the code avoids repeating
itself.
2020-03-25 01:15:18 +00:00
He Sun
65694815a4 Add eventfd file type and system call 2020-03-24 22:16:41 +08:00
LI Qing
f7ce60e764 Fix the emulation of RDTSC instruction with ocall 2020-03-24 22:06:14 +08:00
He Sun
e2edaa49c0 Change the flags used in sendmsg/recvmsg from raw int to memory-safe type 2020-03-24 21:51:04 +08:00
LI Qing
eff91daac9 Add timeout support for futex wait 2020-03-24 20:05:06 +08:00
LI Qing
96876b2935 Add rename for hostfs 2020-03-23 02:45:47 +00:00
LI Qing
23817fc659 Add fstatat and openat system calls 2020-03-09 16:20:51 +00:00
Tate, Hongliang Tian
66dec604e4 Update the version number to 0.10.0 2020-03-09 04:17:48 +00:00
Hui,Chunyang
4ebedd9bf5 Improve simulation mode user experience
Simulation mode and hardware mode can both work without rebuild Occlum.
2020-03-07 09:44:49 +00:00
He Sun
06f7763d55 Fix a bug in poll that modifies input fds 2020-03-07 17:37:52 +08:00
He Sun
74fad28938 Add performance profiler for threads and system calls 2020-03-07 17:35:39 +08:00
zongmin.gu
a1e003ebdb Fix two bugs by updating SDK's stack ranges on user/kernel switch
Before this commit, there are two strange bugs:
1. No backtraces are displayed on panic by Rust; and,
2. Thread local storage in Rust sometimes causes panics.

It turns out that the the root cause of the two bugs are the same: Occlum's
patch to Intel SGX SDK that informs SDK about the stack range of the currnet
LibOS user-level thread. The problem about this patch is that it modifies some
fundamental data structures and Rust SGX SDK does not know the modification.
This causes Rust SGX SDK to panic in certain conditions.

To resolve the conflict for good, this commit gets rid of the patch to Intel
SGX SDK by updating SDK's stack ranges upon user/kernel switch.
2020-03-07 08:17:40 +00:00
LI Qing
6f986855e9 Fix the issue that process resource cannot be freed in some cases
If untrusted app calls "occlum_pal_exec" sequentially or concurrently,
Occlum cannot free the resource of the enclave process correctly.
2020-03-02 14:42:19 +00:00
sanqian.hcy
b08f5b9ceb Add support for SGX simulation mode
1. Use arch_prctl to replace RDFSBASE/WRFSBASE
Ptrace can't get right value if WRFSBASE is called which
will make debugger fail in simulation mode. Use arch_prctl
to replace these instructions in simulation mode.

2. Disable the busy thread in exit_group test
exit_group doesn't have a real implementation yet but test
under SGX simulation mode give core dump for exit_group test.
Disable the busy loop thread and the core dump disappear.

3. Add SDK lib path to LD_LIBRARY_PATH
Linker sometims can't find urts_sim and uae_service_sim when
running. Explicitly add path to LD_LIBRARY_PATH when running
occlum command.

Signed-off-by: sanqian.hcy <sanqian.hcy@antfin.com>
2020-03-01 06:42:33 +00:00
LI Qing
045ea46e9f Extend CPUID emulation for Intel Celeron and newer Intel CPUs 2020-02-28 10:53:38 +00:00
LI Qing
bbd4cd9be2 Add fstat() and poll() for the random device 2020-02-27 03:41:05 +00:00
LI Qing
9f1fa883df Fix GDB cannot work in release build 2020-02-26 06:58:18 +00:00
LI Qing
551fb8f9d8 Add a dummy implementation for file advisory locks
This commits is a dummy implementation of file advisory locks.
Specifically, for regular files, fcntl `F_SETLK` (i.e., acquiring
or releasing locks) always succeeds and fcntl `F_GETLK` (i.e., testing locks)
always returns no locks.
2020-02-25 17:31:02 +08:00
Tate, Hongliang Tian
a6e55881b9 Add ioctls for SGX local attestation 2020-02-19 14:48:12 +00:00
LI Qing
76b90efa8f Fix read_at() in SEFS if offset beyond the end of the file 2020-02-14 08:05:29 +00:00
LI Qing
bd56504b20 Add GDB support for apps running upon Occlum
Please see the "gdb_support" in demos to find out how to
use GDB to debug your apps running upon Occlum.
2020-02-14 07:52:45 +00:00
LI Qing
de904bf628 Refactor the structure of FS subsystem
1. Move the system call handling functions into the "syscalls.rs"
2. Split syscall memory safe implementations into small sub-modules
3. Move the unix_socket and io_multiplexing into "net"
4. Remove some unnecessary code
2020-02-14 06:19:49 +00:00
He Sun
cfa6532768 Fix bugs that fail CentOS Dockerfile 2020-02-14 06:19:48 +00:00
LI Qing
2372ef0d4e Fix make submodule command error 2020-02-10 12:02:23 +00:00
Tate, Hongliang Tian
e96892d348 Update version number to 0.9.0 2020-01-23 10:04:38 +00:00
He Sun
e352a190ea Optimize the perf of sendmsg/recvmsg by allocating untrusted buffers directly
It is slow to allocate big buffers using SGX SDK's malloc. Even worse, it
consumes a large amount of precious trusted memory inside enclaves. This
commit avoids using trusted buffers and allocates untrusted buffers for
sendmsg/recvmsg directly via OCall, thus improving the performance of
sendmsg/recvmsg. Note that this optimization does not affect the security of
network data as it has to be sent/received via OCalls.
2020-01-23 06:58:51 +00:00
Tate, Hongliang Tian
c3d042dcd0 Refactor EDL for adding custom C types easily
Before this commit, using custom C types in ECalls/OCalls defined in Occlum's
EDL is cumbersme. Now this issue is resolved by providing `occlum_edl_types.h`
header file. There are two versions of this file: one is under
`src/libos/include/edl/` for LibOS, the other is under
`src/pal/include/edl/` for PAL. So now to define a new custom C type, just
edit the two versions of `occlum_edl_types.h` to define the type.
2020-01-23 06:58:46 +00:00
Tate, Hongliang Tian
986d1d2e44 Fix ioctl SGX_IOC_GET_EPID_GROUP_ID for EBUSY error
SGX SDK's sgx_init_quote may return SGX_ERROR_BUSY, which is previously not
handled. The implementation of ioctl for /dev/sgx is now fixed to handle this
error.
2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
c6bcbaf442 Fix some typos 2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
671da280d8 Add support for compiling C code as well as Rust in release mode
We can now build all source code (.S, .c, and .rs) under `src/` in release
mode with `OCCLUM_RELEASE_BUILD=1 make` command.
2020-01-23 04:40:54 +00:00
LI Qing
d825351f02 Fix potential overflow or underflow of offset in INodeFile's seek 2020-01-23 04:40:54 +00:00
He Sun
295d52fbe8 Add pipe support for fcntl's F_GETFL and F_SETFL commands 2020-01-23 04:40:54 +00:00
LI Qing
488ec48fe7 Upgrade Rust SGX SDK and its deps to the latest
1. Upgrade Rust SGX SDK to v1.1.0
2. Upgrade Intel SGX SDK to v2.7.1
3. Upgrade Rust to nightly-2019-11-25
2020-01-23 04:40:54 +00:00
LI Qing
040fe89661 Fix the inet socket file to support fcntl()'s F_GETFL and F_SETFL 2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
a84803e951 Refactor Occlum PAL as a shared library
By providing Occlum PAL as a shared library, it is now possible to embed and
use Occlum in an user-controled process (instead of an Occlum-controlled one).

The APIs of Occlum PAL can be found in `src/pal/include/occlum_pal_api.h`. The
Occlum PAL library, namely `libocclum-pal.so`, can be found in `.occlum/build/lib`.
To use the library, check out the source code of `occlum-run` (under
`src/run`), which can be seen as a sample code for using the Occlum PAL
library.
2020-01-23 04:40:54 +00:00
LI Qing
61cf75e68b Add readlink from /proc/self/fd/<fd> to get file paths
* Fix readlink from `/proc/self/exe` to get absolute path of the executable file
* Add readlink from`/proc/self/fd/<fd>` to get the file's real path

Note that for now we only support read links _statically_, meaning that even
if the file or any of its ancestors is moved after the file is opened, the
absolute paths obtained from the API does not change.
2020-01-23 04:40:54 +00:00
LI Qing
daed89007a Add fcntl's subcommands: F_GETFL and F_SETFL
* Modify fcntl system call to support F_GETFL and F_SETFL
* Separate OpenFlags to CreationsFlags, AccessMode and StatusFlags
2020-01-23 04:40:54 +00:00
LI Qing
b610e5b8b8 Fix getdents when the next dir entry cannot fit into the output buffer
The output buffer given to getdents may not be large enough for the next directory
entry. If no directory entries has been loaded into the buffer, just return
EINVAL. Otherwise, return the total length of the directory entries already
loaded in the buffer
2020-01-23 04:40:54 +00:00
Tate, Hongliang Tian
fe926ed8b3 Update version to 0.8.0 2019-12-13 12:36:01 +00:00
He Sun
0cef5b1b53 Add sendmsg/recvmsg syscalls
1. Add a separate net/ directory for the network subsystem;
2. Move some existing socket code to net/;
3. Implement sendmsg/recvmsg with OCalls;
4. Extend client/server test cases.
2019-12-13 12:00:55 +00:00
LI Qing
4ee3396152 Refactor the futex implementation
1. Use multiple futex buckets to reduce lock contention on futex data
strcutures
2. Add FUTEX_REQUEUE support
3. Add the condition variable test case
2019-12-10 06:03:03 +00:00
He Sun
b91566d486 Fix atomic counting in socketpair's bind_until_success 2019-12-07 10:35:27 +00:00
Tate, Hongliang Tian
3c1378b7eb Add ioctls on /dev/sgx for SGX remote attestation
1. Add ioctl command `SGXIOC_GET_EPID_GROUP_ID` for /dev/sgx
2. Add ioctl command `SGXIOC_GEN_QUOTE` for /dev/sgx
3. Add test cases
2019-12-07 10:21:01 +00:00
Tate, Hongliang Tian
814ea21997 Update README for version 0.7.0 2019-11-30 13:41:42 +00:00
LI Qing
ab89421f96 Add sched_yield syscall 2019-11-29 12:03:15 +00:00
Zhengde Zhai
434dff9128 Harden the two enclave entry functions 2019-11-23 15:34:25 +00:00
He Sun
dc14f27a29 Add socketpair syscall
1. Support creating socket pairs of the UNIX domain
2. Add test for socketpair in test/unix_socket
3. Refactor unix_socket test
2019-11-23 15:02:47 +00:00
Tate, Hongliang Tian
9c4391b32d Introduce new infrastructure for ioctls
1. Introduce the new infrastructure for ioctl support
2. Refactor the old ioctls to use the new infrastructure
3. Implement builtin ioctls (e.g., TIOCGWINSZ and TIOCSWINSZ for stdout)
4. Implement non-builtin, driver-specific ioctls (e.g., ioctls for /dev/sgx)
2019-11-22 10:38:34 +00:00
Tate, Hongliang Tian
1024360b8c Refactor File trait with default implementation 2019-11-22 10:38:34 +00:00
He Sun
b0dfc1d69d Add epoll_pwait syscall and the test case
1. Use epoll_wait to support epoll_pwait as there is no signal mechanism
2. The timeout is fixed to zero for not waiting for any signal to come
to speed up
3. Change the test case of server_epoll to use epoll_pwait
2019-11-15 10:01:59 +00:00
He Sun
7e311ed6de Hack epoll_ctl to ignore non-socket fds 2019-11-15 10:01:47 +00:00
Tate, Hongliang Tian
5fa91becfa Build C++ source files under libos/ and pal/ 2019-11-12 16:28:17 +00:00
Tate, Hongliang Tian
91b30c19ae Fix a typo in error message from entry point checking 2019-11-12 16:26:33 +00:00
Tate, Hongliang Tian
83f479ab54 Fix the return value of pal 2019-11-12 16:24:45 +00:00
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
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
Shuang Liu
d61edad08f Randomize the file names of SEFS inodes on the host FS 2019-09-06 15:08:13 +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
347791f235 Add install target for Makefile 2019-08-31 06:01:16 +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
Wang Runji
c656776eb1 Fix MountFS sync 2019-08-02 08:34:40 +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
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
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
散樗
2553298b1d Handle cpuid and rdtsc instruction
Init support for cpuid and rdtsc instruction handling in occlum.

This patch includes:
1. cpuid exception handler for all information leaves;
2. rdtsc exception handler;
3. handler registration;
4. cpuid test;
5. rdtsc test.

Signed-off-by: 散樗 <kailun.qkl@antfin.com>
2019-07-18 13:51:50 +08:00
Tate, Hongliang Tian
56c69b5f3c Refactor mmap implementation
1. Add a full test suite for mmap
2. Implement file-backed memory mapping
3. Implement fixed, anonymous memory mapping
4. Implement hinted, anonymous memory mapping
5. Implement munmap that covers partial/multiple memory mappings
2019-07-01 11:56:04 +08:00
Tate, Hongliang Tian
3465477cc1 Fix two bugs that prevents compilation and tests working 2019-04-29 00:01:17 +08:00
WangRunji
413586f729 add integrity_only_opt and sgx_file_cache feature 2019-04-26 22:48:00 +08:00
WangRunji
6e871f7948 reformat code using cargo fmt 2019-04-26 21:26:30 +08:00
WangRunji
dd3de96b8e hack unix socket for php 2019-04-24 19:25:09 +08:00
WangRunji
9797a64f06 enable unix socket and add test for it 2019-04-24 13:28:35 +08:00
WangRunji
9106bd46f2 fix for php. include incomplete code for UnixSocket 2019-04-23 22:00:38 +08:00
WangRunji
f846ba11f2 fix wait4 not removing child 2019-04-23 14:00:44 +08:00
WangRunji
0437e81f36 fix impl File for Stdin/Stdout 2019-04-23 12:58:28 +08:00
WangRunji
26189dddaa implement fcntl & ioctl for socket. fix lighttpd performance 2019-04-23 01:43:41 +08:00
WangRunji
1326924dbb fix errno = 0 and introduce macro 'try_libc' 2019-04-23 00:49:37 +08:00
WangRunji
141094e95e fix return value from libc::ocall 2019-04-22 21:55:57 +08:00