Commit Graph
1147 Commits
Author SHA1 Message Date
Michał Kowalczyk 786b10a00f [Pal/FreeBSD] Remove FreeBSD PAL
FreeBSD PAL is not maintained anymore, is neither built nor tested in
our CI and most likely stopped working long time ago. Currently it only
confuses people implementing changes in PALs (should they also fix bugs
in FreeBSD PAL if they can't test it?) and gives a false impression that
we support FreeBSD hosts.
2020-01-13 23:22:51 +01: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
borysp 599425ed07 [LibOS] Fix some bugs related to O_DIRECTORY handling 2020-01-10 23:31:53 +01:00
Wojtek Porczyk c6a39c0e41 [CI] Have list of files that we don't complain about
Jenkins should complain about new files and those already fixed. After
fixing a file completely, the file path should be removed from the list.

This is helpful for pylint, because some errors, mostly from category
"refactor", are attributed to the line with function's signature and are
liable to be missed by the heuristics.
2020-01-09 23:22:40 +01:00
Wojtek Porczyk 5468c6ecf3 [Pal] Make pylint happy
Fixes warnings in: pal-sgx-sign, pal-sgx-get-token and pal-gdb.py.

Ignores them in aesm_pb2.py and Documentation/conf.py. The former is
autogenerated, the latter is mostly irrelevant. If someone starts
messing with it, we could re-enable this, but Sphinx' requirements clash
with pylint, mostly on invalid- name, because the configuration
variables are expected lower-case.
2020-01-09 23:22:40 +01:00
Michał Kowalczyk f1c334357c Reformat repository to our clang-format rules (2nd iteration) 2020-01-09 02:35:50 +01:00
Isaku Yamahata f8f6a0c42f [LibOS] Replace init_fs_base() with update_fs_base()
Now init_fs_base() is same to update_fs_base() except struct shim_thread
argument which is unused.
2020-01-08 01:20:26 +01:00
Isaku Yamahata 1902c3862b [LibOS] Use set_cur_thread() to associate shim_tcb_t and shim_thread
Uniformly use set_cur_thread() to associate shim_tcb_t to struct
shim_thread. Remove unnecessary logic from init_fs_base() and
update_fs_base().
2020-01-08 01:20:26 +01:00
Isaku Yamahata 211c8ce559 [Pal/Linux-SGX] Clean up PAL_TCB_LINUX and rename to PAL_TCB_URTS
PAL_TCB_LINUX of Pal/Linux-SGX is unrelated to PAL_TCB because untrusted
code is independent from trusted code. Remove PAL_TCB from PAL_TCB_LINUX
and make PAL_TCB_LINUX visible only to untrusted code. Also, rename to
PAL_TCB_URTS to make it clear that it belongs to untrusted code.
2020-01-08 01:12:58 +01:00
Isaku Yamahata 29bd2bdf9c [LibOS] Use uint64_t intead of unsigned long for GP register type 2020-01-08 01:06:58 +01:00
Isaku Yamahata a7cb199b9a [LibOS] Optimize shim_get_tcb() and its variants
- apply SHIM_TCB_GET() and SHIM_TCB_SET()
- remove dead code
2020-01-08 01:06:52 +01:00
Dmitrii Kuvaiskii 1b10217cee [LibOS] test/apps: Enable select/pselect/poll/epoll tests in LTP 2020-01-07 13:57:45 -08:00
Dmitrii Kuvaiskii da2dd37dd8 [LibOS, Pal/{Linux,Linux-SGX}] Better emulation of polling
This commit improves the emulation of polling mechanisms (select,
pselect, poll, ppoll, epoll_wait) and cleans up the corresponding
code:
- New DkObjectsWaitEvents() PAL interface, replaces the inefficient
  DkObjectsWaitAny() interface. This interface closely resembles
  Linux/POSIX poll() in semantics.
- Improved shim_do_epoll_wait() implementation, now using the new
  DkObjectsWaitEvents() interface.
- Improved shim_do_poll() implementation, now using the new
  DkObjectsWaitEvents() interface.
- Small cleanups of polling code.
2020-01-07 12:11:00 -08:00
Dmitrii Kuvaiskii 56bc2b49ad [LibOS] Comprehensive cleanup of epoll_create()/epoll_ctl()/epoll_wait()
Accurate cleanup of shim_do_epoll_create1(), shim_do_epoll_ctl(),
shim_do_epoll_wait(), and other epoll helper functions. This cleanup
also adds error handling (missing previously).

The commit makes (most of) the corresponding LTP tests pass now.

Note that epoll semantics are still incorrect and inefficient: current
epoll_wait() emulation returns only one event to the user.
2020-01-07 12:11:00 -08:00
Dmitrii Kuvaiskii 3e2c8ed9d2 [LibOS] Comprehensive cleanup of poll()/ppoll()/select()/pselect()
Accurate cleanup of shim_do_poll(), shim_do_ppoll(), shim_do_select(),
and shim_do_pselect6(). This cleanup also adds error handling (missing
previously).

The commit adds four LibOS regression tests on poll, ppoll, select,
and pselect mechanisms. Also, the corresponding LTP tests pass now.
2020-01-07 12:11:00 -08:00
Dmitrii Kuvaiskii 1ea4535ebd [Pal/Linux] db_pipes.c: Remove redundant code in pipe_attrquerybyhdl() 2020-01-07 12:11:00 -08:00
Dmitrii Kuvaiskii dc30dce549 [Pal/{Linux,Linux-SGX}] Cleanup of db_object.c
This commit refactors db_object.c of Linux and Linux-SGX PALs:
- Remove _DkObjectWaitOne() and incorporate its special-case of
  waiting on single mutex/event in _DkObjectsWaitAny().
- Refactor _DkObjectsWaitAny() for readability.
- Remove unused DEFAULT_QUANTUM and TRACE_HEAP_LEAK.
2020-01-07 12:11:00 -08:00
Thomas Knauth 15be96fbae [LibOS] Correctly release resources in str_close() 2020-01-07 03:52:31 +01:00
Dmitrii Kuvaiskii 9efa4361fe [Pal/Linux-SGX] Add sgx.ra_accept_configuration_needed manifest option
This commit adds `sgx.ra_accept_configuration_needed` manifest option
to handle the case when SGX remote attestation from IAS returns status
CONFIGURATION_NEEDED (which means that this SGX platform is not known
to be compromised but has e.g. hyper-threading enabled).
2020-01-06 19:14:20 -08:00
Dmitrii Kuvaiskii 36dfe1665e [LibOS] Disallow eventfd emulation by default
Eventfd emulation currently relies on the host, thus eventfd syscalls
are disallowed by default due to security concerns. To use them, they
must be explicitly allowed through "sys.allow_insecure_eventfd" in
the manifest.
2020-01-06 17:22:29 -08:00
borysp 1bf6423384 [LibOS/Pal] Replace hardcoded URI prefix strings 2020-01-06 16:17:26 -08:00
Michał Kowalczyk ea1a1d961c [LibOS] tests: Fix missing/wrong return values from main() 2020-01-06 03:49:23 +01:00
Dmitrii Kuvaiskii 88f7fae9f8 [Pal/{Linux,Linux-SGX,FreeBSD}] Replace stream_in & stream_out with one stream socketpair
Previously, parent and child processes communicated via two unidirectional
pipes: process.stream_in and process.stream_out. Now these pipes were replaced
with bidirectional socketpairs, so there is no need to distinguish between
read and write ends. This commit merges stream_in and steam_out FDs into one
stream FD, and simplifies corresponding code (especially SGX implementation).
2020-01-03 19:00:07 -08:00
Dmitrii Kuvaiskii 522dd19760 [Pal/Linux-SGX] Remove dead code left from old local attestation protocol
Graphene now has a reworked parent-child verification and SGX local
attestation protocol. Remove the dead commented-out code that is not
needed anymore, along with unused macros.
2020-01-03 19:00:07 -08:00
Dmitrii Kuvaiskii 8a7c8bdceb [Pal/{Linux,Linux-SGX,FreeBSD}] Replace pipe() with socketpair()
Graphene already emulates pipes via UNIX domain socketpairs. The only
place where Graphene still uses host pipes is in DkCreateProcess(),
for communication and checkpoint send/receive between parent and child.

UNIX domain socketpairs are more convenient than pipes and allow
bidirectional communication, which is useful for IPC encryption via
SSL/TLS. This commit replaces all lingering uses of pipes with
socketpairs.
2020-01-03 19:00:07 -08:00
Dmitrii Kuvaiskii eda813ec47 [Pal/{FreeBSD,Linux}] Remove unused USE_PIPE_SYSCALL and PIPE_USE_SENDMSG_RECVMSG
These macros and the associated code are useless and not tested.
2020-01-03 19:00:07 -08:00
Isaku Yamahata af7a7c2f3a [LibOS] clone: Remove stale comment 2020-01-01 20:12:26 +01:00
Dmitrii Kuvaiskii 7d99d4788c [LibOS,Pal] Remove Graphene IPC completely
Graphene IPC (GIPC) was introduced to perform faster bulk IPC by sharing pages as copy-on-write
across processes. This feature became stale, and it was shown that recent Linux kernels (4.2+)
have zero-copy transfers over UNIX sockets and exhibit similar performance. GIPC is not built and
not tested in Jenkins. Also, GIPC does not work under SGX. This commit completely removes GIPC.
2019-12-30 12:17:51 -08:00
Wojtek Porczyk 7b057d957a [CI] fix linting test names
Test classes and functions are named TC_01_Example and test_012_example,
respectively. Those are not conforming to the usual style enforced by
pylint but that's okay.
2019-12-20 15:31:45 +01:00
borysp 3d662b49cd [LibOS] Add futexes tests 2019-12-19 22:04:12 -08:00
borysp 6cfaf420b3 [LibOS] Rework futexes implementation
This commit completely rewrites futex implementation to (hopefully)
remove all races (both on memory access level and between waits and
wakes), make it compatible with actual Linux implementation and make
it more maintainable and readable.
2019-12-19 22:04:12 -08:00
Thomas Knauth 0f0eb95732 [Pal/lib] Fetch and build mbedtls 2.16.3 from official repo 2019-12-19 21:03:56 -08:00
Thomas Knauth de5efcd53d [Pal/lib] Add strcmp() function 2019-12-19 20:07:06 -08:00
Thomas Knauth 3174ec726c [Pal/lib] Fix snprintf() function signature 2019-12-19 20:07:06 -08:00
Thomas Knauth 9e0f50ee92 [Pal/Linux-SGX] Set ready_for_exceptions earlier during enclave initialization
Previously, there was a segfault if a child enclave issued a cpuid instruction
during init_child_process(), because the enclave was not yet set up to handle
exceptions. This commit moves this set up earlier in initialization sequence.
2019-12-19 20:07:06 -08:00
Wojtek Porczyk ec416115eb [LibOS] test/apps/ltp: Fix reporting of results v1.0.1 2019-12-18 12:14:38 +01:00
Dmitrii Kuvaiskii b8a955c826 [LibOS/regression] Add test for host root FS
Graphene supports a special "root FS" parameter in the manifest:
"fs.root". This commit adds a test that uses this parameter.
2019-12-18 02:59:02 -08:00
Dmitrii Kuvaiskii 05cc50945f [LibOS] Allow inaccessible files during getdents()
Previously, if user performed getdents() on a directory containing
inaccessible files (because user doesn't have permission), whole
getdents failed with -EACCES. This is incorrect behavior: files must
still be listed. This commit fixes the root cause of this bug by
marking inaccessible files as DENTRY_NEGATIVE.
2019-12-18 02:59:02 -08:00
Dmitrii Kuvaiskii 860e1083a2 [LibOS] test/regression: Enable exit_group test on SGX
Previously, exit_group test was disabled on Linux-SGX PAL. It was
disabled because the PAL incorrectly exited threads. The latest
commits fix this, and the test can be re-enabled.
2019-12-18 01:56:25 -08:00
Dmitrii Kuvaiskii 7c45430355 [LibOS] Remove the data race on thread::is_alive
Previously, there was a data race on thread::is_alive between one thread
checking whether it is the last thread alive via check_last_thread() and
another thread exiting via thread_exit(). The former checks if is_alive
is true, the latter sets it to false. However, the exiting thread will
truly exit only after it called DkThreadExit(), thus the race on is_alive
led to scenarios where two threads believe to be the last threads alive
and compete on terminating Async Helper/IPC threads and exiting the whole
process. This commit introduces cleanup_thread() called by Async Helper
to set is_alive to false and delete the thread, freeing its resources.
The data race is thus removed, and shim_thread object leak is prevented.
2019-12-18 01:56:25 -08:00
Dmitrii Kuvaiskii 7301453940 [Pal/Linux-SGX] Do not try to munmap not-mmapped stack of main thread
In Linux-SGX PAL, the main thread's stack is provided by host Linux, unlike
child threads which stacks are mmapped by the PAL. Therefore, the main
thread's stack must not be munmapped, unlike child threads' stacks.
Previously, PAL tried to munmap stack of even the main thread, leading to
spurious segfaults in e.g. `abort_multithread` test.
2019-12-18 01:56:25 -08:00
Dmitrii Kuvaiskii b4673dc171 [Jenkins] Add Redis test to all Jenkins pipelines
Redis is tested with select() syscall on 16.04 pipelines and with
epoll() on 18.04 pipelines.
2019-12-14 12:53:45 -08:00
Dmitrii Kuvaiskii c47642b318 [Jenkins] Split SGX pipelines into two: tests and apps
Previously, it took more than 30-45 minutes to run one SGX pipeline.
This commit splits that SGX pipeline into two: one runs LibOS/PAL
tests and LTP tests, the other one runs only application examples.
The times to run each of these pipelines are roughly the same.
Splitting SGX pipelines decreases wait time for Jenkins in half.
2019-12-14 12:53:45 -08:00
Isaku Yamahata c6042ce762 [LibOS] test/apps: Enable ltp/kill12 2019-12-13 09:24:15 +01:00
Wojtek Porczyk 3abc77dc1d [CI] Fix lint issues 2019-12-11 17:16:09 +01:00
Wojtek Porczyk efbf2706dd [CI] Run shellcheck as part of Jenkins pipelines
The pipeline is failed only when pylint whines about the code actually
touched as part of the pull request.

The `run-shellcheck` script is provided so it can be reused, maybe in
`.git/hooks/pre-push`.
2019-12-11 17:16:09 +01:00
Wojtek Porczyk 4114337da0 [CI] Run pylint as part of Jenkins pipelines (18.04)
The pipeline is failed only when pylint whines about the code actually
touched as part of the pull request.

Ubuntu 16.04 pipelines are not enabled, since they are affected by this
bug, since fixed: https://github.com/PyCQA/pylint/issues/1216.

The `run-pylint` script is provided so it can be reused, maybe in
`.git/hooks/pre-push`.
2019-12-11 17:16:09 +01:00
Isaku Yamahata c3a6444ce6 [Pal] pal.map: Add "DO NOT MODIFY" warning to generated file 2019-12-10 22:57:21 -08:00
Isaku Yamahata b8d824af94 [Pal/Linux-SGX] pal-sgx-sign: Prepend "DO NOT MODIFY" to autogenerated manifest 2019-12-10 22:57:21 -08:00