Commit Graph
688 Commits
Author SHA1 Message Date
Isaku Yamahata afddf5c4cc [LibOS] Build test/{benchmark, inline, regression} 2020-02-05 23:21:06 -08:00
Isaku Yamahata 0a7e3dd127 [LibOS,Pal] Move header files from Pal/lib/ under Pal/include/ 2020-02-05 23:21:06 -08:00
Isaku Yamahata 8d65898d91 [LibOS,Pal] Eliminate creation of host_endian.h symlink
This file should be included via include path, not via a symlink.
2020-02-05 23:21:06 -08:00
Isaku Yamahata cff1146892 [LibOS,Pal] Modify Makefiles' logic to simplify checks on SYS
The goal of `$(SYS)` check in Makefiles is to skip all targets on
unsupported systems. This commit defines a default goal `all` as
a no-op for simplicity.
2020-02-05 23:21:06 -08:00
Isaku Yamahata fc0b5c4012 [LibOS,Pal] remove unnecessary .PHONY: default in Makefiles 2020-02-05 23:21:05 -08:00
Isaku Yamahata fa2ed00153 [LibOS] Include Makefile.{config, rule} in test/*/Makefile 2020-02-05 23:21:05 -08:00
Isaku Yamahata 647a8f3953 [LibOS,Pal] Consolidate common CFLAGS in Makefile.configs 2020-02-05 23:21:05 -08:00
Isaku Yamahata 29d907a573 [LibOS,Pal] Consolidate DEBUG, WERROR, PROFILE in Makefile.configs 2020-02-05 23:21:05 -08:00
Isaku Yamahata 88ea5164d6 [LibOS,Pal] Makefiles: use += instead of = in CFLAGS/LDFLAGS/etc 2020-02-05 23:21:05 -08:00
Isaku Yamahata c126c10452 [Pal] Move user_start.S under Pal/crt_init/ directory 2020-02-05 23:21:05 -08:00
Isaku Yamahata 50bdec8a23 [LibOS,Pal] Move Makefile.Host under Scripts/ 2020-02-05 23:21:05 -08:00
Isaku Yamahata 8fc9f0d948 [LibOS] native/Makefile, benchmark/Makefile: Use implicit pattern rules 2020-02-05 23:21:05 -08:00
Isaku Yamahata 35dd8c9423 [LibOS,Pal] Consolidate export DEBUG in Makefile.configs 2020-02-05 23:21:05 -08:00
Isaku Yamahata 0912f20ccf [LibOS,Pal] Unify the setting of CC and remove raw gcc invocations 2020-02-05 23:21:05 -08:00
Isaku Yamahata dd086816b5 [LibOS,Pal] Define AR and ARFLAGS properly 2020-02-05 23:21:05 -08:00
Isaku Yamahata 0612fc8657 [LibOS] Cleanup test/inline/Makefile 2020-02-05 23:21:05 -08:00
Isaku Yamahata a1c534ec56 [LibOS/shim/test] Rename .*.c files to .c files 2020-02-05 23:21:05 -08:00
Isaku Yamahata 9ef2251d66 [LibOS,Pal,Scripts] Add and use recipe to create manifest from template 2020-02-05 23:21:05 -08:00
Isaku Yamahata 732712e23e [LibOS,Pal] Move makefile libraries under Scripts/
This commit moves Makefile.configs, Makefile.rules, and Makefile.Test
under Scripts/ and adjusts their includes.
2020-02-05 23:21:04 -08:00
Isaku Yamahata e6d90c5bd8 [LibOS] test/apps: Update LTP to use its own Makefile.Test
This removes the dependency of test/apps/ on LibOS/shim/tests/Makefile.Test.
Thus, a follow-up commit can safely remove that file.
2020-02-05 23:21:04 -08:00
Isaku Yamahata a09c0897f5 [LibOS] Cleanup of shim_thread::shim_signal_logs
- Make struct shim_signal_log opaque.
- Introduce signal_logs_alloc() and signal_logs_free() to properly
  initialize and free signal_logs.
- Introduce helper signal_logs_pending() to simplify signal_logs check.
- Rename shim_signal_log's {head, tail} to {tail, head}.
- Fix PID leak during get_new_thread().
2020-02-05 13:16:12 -08:00
Simon Gaiser 0daeed847f [Jenkins] Check for missing gitignores and fix found issues 2020-02-05 02:46:13 +01:00
Dmitrii Kuvaiskii bca88eb94d [LibOS] test/apps: Allow SSL/TLS connections in Apache httpd 2020-02-04 18:25:40 -08:00
Dmitrii Kuvaiskii c685e56e67 [LibOS] Update TYPE_DEV handles with correct function pointers in dev_ops
For device handles, `info.dev.dev_ops` contains function pointers into
LibOS. They may become invalid due to relocation of LibOS text section
in the child process on fork. This commit forces an update of these
function pointers.
2020-02-04 18:25:00 -08:00
Simon Gaiser 9052837dfc [Make] Improve download handling
Instead of implementing downloading of external resources in every
Makefile again, use one script. This script adds the following
features:

 - Always check the download against a known SHA-256 hash.

 - Support caching of downloaded resources (set DL_CACHE=/some/dir).

 - Allow offline builds if all files are cached. If DL_OFFLINE=true the
   build will never attempt to download anything.
2020-02-05 00:41:10 +01:00
Isaku Yamahata d379bba600 [LibOS] test: Add missing dependencies in Makefiles 2020-02-04 02:49:18 +01:00
Simon Gaiser 7377a787bc [Makefile] Add distclean target
Before, there was no target that cleaned up downloaded sources. This
commit adds a distclean target to match the 'apps' Makefiles.
2020-02-04 01:15:08 +01:00
borysp 5c37c4d21a [LibOS] Miscellaneous bugfixes, mostly found by the previous commit
The previous commit added some asserts on locks state, which unveiled
a bunch of bugs. This fixes all of them and a bit more found in the
process.
2020-02-02 17:58:51 +01:00
borysp bdc6a48c2c [LibOS] Add a bunch of asserts on locks state 2020-02-02 17:58:39 +01:00
Simon Gaiser 80d34637d0 [LibOS] test/apps/curl: Test against local server 2020-02-01 00:41:58 -08:00
Dmitrii Kuvaiskii 4ad98502fe [LibOS,Pal] Introduce PAL_CREATE_DUALSTACK for IPV6_V6ONLY emulation
Previously, Graphene didn't have emulation of setsockopt(IPV6_V6ONLY).
This flag signals that application doesn't want to create dual-stack
socket (i.e., it wants to bind both IPv4 and IPv6 connections on the
same port).

In reality, different applications require different behavior: e.g.,
Redis sets IPV6_V6ONLY whereas Apache with SSL/TLS unsets it, and
always emulating as set or unset leads to failure of one of these
apps. This commit introduces emulation of IPV6_V6ONLY via a generic
PAL_CREATE_DUALSTACK flag passed to DkStreamOpen(.., create, ..).

Notice that it is impossible to emulate IPV6_V6ONLY as other flags
such as TCP_NODELAY because IPV6_V6ONLY flag makes sense only before
bind, whereas Graphene historically applies other flags only after
bind() syscall. Therefore we introduced PAL_CREATE_DUALSTACK.
2020-02-01 04:24:58 +01:00
Isaku Yamahata a256338634 Add generated-cacert.h and glibc-build to .gitignore 2020-01-29 22:23:13 +01:00
Dmitrii Kuvaiskii 735f54d22c [LibOS,Pal/{lib,Linux-SGX}] Add TLS-PSK protection to process checkpoint IPC
Previously, Graphene-SGX did not protect send/recv of checkpoint from
parent to child. This leaked all memory contents of the parent process.

This commit adds TLS-PSK (TLS with Pre-Shared Key) wrapper for process
communication. Graphene-SGX already has the logic for SGX-based local
attestation and generation of the shared key for each parent <-> child
communication channel via Diffie–Hellman key exchange. This commit
uses this pre-shared key to create an mbedTLS-based session based on
UNIX domain socketpair (parent.process.stream <-> child.process.stream).

_DkStreamSecure{Init,Free,Read,Write} internal Linux-SGX PAL functions
are added and used during child process creation and sending of the
parent-generated checkpoint. These functions are backed by crypto-layer
lib_SSL{Init,Free,Read,Write} functions which in turn use mbedTLS.
Configuration of mbedTLS is expanded to support TLS-PSK; note that for
entropy source we use only rdrand instruction inside SGX enclave (i.e.,
no untrusted host-platform sources of entropy). The only ciphersuite
currently supported for IPC is MBEDTLS_TLS_PSK_WITH_AES_128_GCM_SHA256.

This commit adds protection only for checkpoint IPC. After the checkpoint
is sent/received, the parent/child processes downgrade their sockets to
plain non-secure ones (by disabling TLS). This is done because child
may spawn a grandchild that also wants to communicate with grandparent,
but it is impossible for multiple processes to share same TLS context.

Additionally, this commit sanitizes "process" PAL handles during send-
handle checkpoint send (via DkSendHandle): shared key and TLS context
are zeroed out.
2020-01-28 13:05:48 -08:00
Michał Kowalczyk e09ac87321 [LibOS] test_libos.py: Simplify test_001_strict_fail 2020-01-28 17:03:32 +01:00
Isaku Yamahata 621b6a34b9 pylint: Eliminate pylint warnings in test_{pal,libos}.py 2020-01-28 03:45:04 +01:00
Dmitrii Kuvaiskii a1c340b60b [LibOS] Add EINVAL and EFAULT checks for {get,set}sockopt() 2020-01-25 22:39:56 +01:00
Dmitrii Kuvaiskii eb4849d23a [LibOS] Allow all getsockopt() before bind()
Previously in Graphene, some getsockopt() syscalls, e.g. TCP_NODELAY,
failed because an underlying PAL handle was't created for the LibOS
handle until bind() was called. Thus, a sequence of accept() and
getsockopt() failed. This commit fixes this by returning default
socket options (possibly augmented with setsockopt values). Test
case is also provided.
2020-01-25 22:39:56 +01:00
Yunjong Jeong 9df502b4ab [Pal/Linux-SGX] Add manifest option sgx.enclave_pal_file
Path to enclave file had been a fixed string that is determined at
build time. Therefore Runtime binares were not allowed to move
their location. This commit adds sgx.enclave_pal_file manifest
option to specify the uri of libpal-Linux-SGX.so.
2020-01-26 01:54:46 +09:00
Dmitrii Kuvaiskii 5784d97375 [LibOS] Allow MSG_PEEK on recv()
Previously, Graphene failed if recv() contained MSG_PEEK flag. This
resulted in many TLS-based applications failing, including Nginx,
Apache, and Lighttpd in SSL/TLS mode. This commit adds emulation of
MSG_PEEK at LibOS level. A simple TCP test case is provided.
2020-01-25 02:26:59 +01:00
Dmitrii Kuvaiskii 3def3a6ba6 [LibOS] Allow poll/ppoll/select/pselect on regular and dev files
Previously, Graphene incorrectly handled poll/ppoll/select/pselect
of regular and dev files like `/dev/urandom`: it tried to perform
an actual host-OS poll on these files. However, poll of such files
must be emulated completely inside LibOS. This commit adds this
special case to poll/ppoll/select/pselect. A test case is supplied.
2020-01-25 02:26:59 +01:00
Dmitrii Kuvaiskii 4485f5af98 [LibOS] Allow LibOS handles without backing PAL handles in epoll
Previously, Graphene failed with -EPERM on epoll_ctl(EPOLL_CTL_ADD)
of a LibOS shim handle without a backing PAL handle. However, it is
possible for a LibOS socket handle to not have a PAL handle: if
user app first creates the handle via socket(), then adds it to epoll
via epoll_ctl(), and only then performs bind() at which point PAL
handle is finally created. This commit removes this restriction.
2020-01-25 02:26:59 +01:00
borysp 2ddd53b102 [LibOS] Add spinlocks asserts to futexes 2020-01-21 22:45:57 +01:00
borysp 6a6a852fb6 [LibOS] Add error handling to helper threads 2020-01-20 18:32:02 -08:00
Michał Kowalczyk 716029400b [LibOS] test/apps: Remove workarounds for allowed_files bug 2020-01-20 19:21:24 +01:00
borysp 12efb484f3 [LibOS] Add VMA_TAINTED in mprotect 2020-01-18 18:33:42 +01:00
Dmitrii Kuvaiskii 57f1bdd47f [LibOS] Fix type of checkpoint's total memory size variable
Checkpoint's total memory size is stored in shim_cp_store::mem_size
field. Previously, this field was of type `int`. When a process
allocates more than 2GB of memory and then tries to spawn a child,
the checkpoint send/receive fails due to int overflow of mem_size.
This commit simply changes mem_size type to `size_t`. This is enough
to make the bug go away on e.g. a huge Python app with TensorFlow.
2020-01-17 17:36:07 -08:00
Dmitrii Kuvaiskii 40c08ff75a [LibOS, Pal/{Linux,Linux-SGX}] Remove DkObjectsWaitAny()
Now Graphene supports an improved version of DkObjectsWaitAny() with
correct polling semantics -- DkObjectsWaitEvents(). This makes
DkObjectsWaitAny() obsolete. This commit removes DkObjectsWaitAny()
and replaces it with:
- DkSynchronizationObjectWait() to wait on a single synchronization
  object like mutex or event.
- DkStreamsWaitEvents() to wait on stream-like objects (this is the
  renamed DkObjectsWaitEvents()).

The corresponding tests are fixed to use the new PAL interfaces.
Also, IPC helper and Async helper threads are significantly refactored
to make better use of DkStreamsWaitEvents().
2020-01-14 20:31:40 -08:00
jack.wxz c6b9ea1baf [LibOS] Add more cases to update inode number and file size
This commit adds more cases to the chroot FS to update file metadata:
- update inode number immediately after creating a new file;
- update file size after writing a non-mmapped file.

This commit also adds corresponding LibOS tests.
2020-01-13 20:26:18 -08:00
jack.wxz 99193dc1f7 [LibOS] Avoid gaps due to partial reads in iovecs in recvmsg()
Syscall recvmsg() accepts an array of buffers (iovecs). This buffers are
filled in array order. POSIX does not allow to fill e.g. iov[0] only
partially before proceeding to iov[1]. This commit makes recvmsg()
emulation compliant with this requirement.

Also, this commit fixes a small performance issue when recvmsg() would
overwrite the same received-address info over and over.
2020-01-10 19:19:33 -08:00
borysp 5cb7623e8d [Tests] Update tests submodule commit 2020-01-10 23:31:53 +01:00