Commit Graph
957 Commits
Author SHA1 Message Date
Don Porter f003fb2500 Do not merge. Just a CI test 2019-10-02 10:14:28 -04:00
Michał Kowalczyk a0a996904d [LibOS] Fix a typo in large_dir_read test 2019-10-02 03:23:33 +02:00
Michał Kowalczyk 44e186c503 Clean up asserts
- Make assert() a no-op in non-debug builds.
- Use static_assert for compile-time asserts.
- Fix assert() implementation (previous version didn't work for
  expressions with types larger than long, it also always printed
  `(value:0)`).
- Clean up calls to asserts.
2019-10-02 03:22:52 +02:00
Michał Kowalczyk a6e1524e6e Clean up handle_ops and PAL_HANDLE usage 2019-10-02 03:22:28 +02:00
Dmitrii Kuvaiskii da21b2e000 [LibOS] test/apps: Move benchmark-http.sh to common_tools
This commit concerns web-server examples: Apache, Nginx, and Lighttpd.
Previously, benchmark-http.sh bash script was located under lighttpd
directory, and Apache and Nginx had symbolic links to it. This is
unintuitive. This commit moves benchmark-http.sh to a newly created
common_tools directory, and all web-server examples have symbolic links
to this new dir.
2019-10-01 19:28:20 -07:00
Wojtek Porczyk e0b690f22e [PAL] fix pal_loader SGX invocation
This fixes regression from 2d29f7aaeb
2019-10-01 23:39:42 +02:00
Thomas Knauth 9f37aa77b1 [Pal/Linux] Do not set SO_LINGER on socket during socket_close()
Previously, Linux PAL set SO_LINGER with a zero timeout before closing
the socket. Among other things, this led to ab (ApacheBench) reporting
failed requests when running nginx/lighttpd on Graphene, because the TCP
connection was not closed cleanly. This commit removes setting
SO_LINGER, similarly to Linux-SGX PAL.
2019-10-01 13:55:01 -07:00
Thomas Knauth c6a0151baf [LibOS] Fix and add a test case for resource leak on file close 2019-10-01 16:18:38 +02:00
Dmitrii Kuvaiskii b81c808589 [LibOS] test/apps: Rewrite Nginx example 2019-09-30 21:53:48 -07:00
Isaku Yamahata 55e0bb1c6a [LibOS] Force variable update on tcb.test_range.has_fault in test_user_memory()
In test_user_memory(), a memory range is tested via probing of each page
in the range. If the memory page was not allocated, it leads to a
segfault which is captured by the LibOS memfault_upcall() and reported
in the variable tcb.test_range.has_fault. However, the compiler may
optimize away accesses to this variable in test_user_memory(), believing
it is never updated anywhere else. This commit introduces a memory
barrier to prevent this compiler optimization (same for test_user_string()).
2019-09-30 20:56:18 -07:00
Jia Zhang 0674d1e9bc [Pal/Linux-SGX] pal-sgx-sign: Always output sgx.static_address
Previously, sgx.static_address was not recorded in generated
.manifest.sgx for PIE executables. The value is 0 by default, this
change only makes it explicit.
2019-10-01 01:53:12 +02:00
Jia Zhang 9f037adbe0 [Pal/Linux-SGX] Refactor main function of pal_loader
- Avoid opening manifest file twice
  If the specified file is a manifest, its fd can be sent to load_enclave()
  directly.

- Kill hard-coding constant
  Use static_strlen(foo) instead.

- Add error handling
  Check the return value of alloc_concat(), and use strendswith() to prevent
  from buffer underflow caused by short base name of input file path.

- Enhance readability
  Include renaming variables and comment changes.
2019-10-01 01:19:39 +02:00
Michał Kowalczyk b7e87c3ed4 [Pal] Delete some unused files 2019-10-01 00:48:00 +02:00
Michał Kowalczyk 6e67342ba8 [LibOS] Fix incorrectly git-ignored glibc-patches dir 2019-10-01 00:48:00 +02:00
Michał Kowalczyk 6ba48bdf59 [LibOS] shim_profile: Simplify no-op macros 2019-10-01 00:48:00 +02:00
Michał Kowalczyk 62cbf79603 Fix a bunch of typos 2019-10-01 00:48:00 +02:00
Jia Zhang 1bb5047403 [Pal/Linux-SGX] Fix checking of the size of a signature file
The format of enclave signature should strictly match the spec.
2019-10-01 00:05:48 +02:00
borysp 323be6717d [LibOS] Change minimal file descriptor number to be 0
Previously, set_new_fd_handle() started searching for the first free fd
from 1 not 0. This commit fixes this, plus refactors this function.
2019-09-30 15:49:32 -07:00
Jia Zhang 135ffa15fd [Pal/lib] Fix parsing the key portion of config in the manifest
The check whether there are still any characters to read must happen
*after* skipping the whitespaces between key portion and equal mark.
2019-09-30 15:03:34 -07:00
Isaku Yamahata 951219cac7 [Pal/Linux] Block async signals on thread exiting
After the Linux PAL frees the thread's signal stack and TCB but before
the thread is actually destroyed by Linux, an arriving async signal on
this thread will result in a segfault. This commit simply blocks all
async signals before proceeding with freeing thread's resources.
2019-09-30 15:22:03 +02:00
Isaku Yamahata 912761b1e0 [Pal/Linux] Allocate threads' stacks using malloc
_DkVirtualMemoryAlloc() can allocate memory overlapping with
pal_control.user_address. In this case, thread stack could get corrupted
by LibOS, typically resulting in SEGV.
2019-09-28 16:32:59 +02:00
Dmitrii Kuvaiskii 0b6809fc19 [LibOS] Do not get/put handles when adding/removing from epoll
Previously, Graphene explicitly incremented refcount of a handle added
to/removed from epoll, in epoll_ctl(EPOLL_CTL_ADD/EPOLL_CTL_DEL).
However, according to epoll(7), closing a file descriptor causes the
FD (handle) to be removed from all epoll sets. In other words,
adding/removing a handle to/from epoll must not count towards refcount
of the handle. Otherwise the handle remains dangling in the epoll set
even if it was close()'d (this particular case led to Nginx segfault).
This commit removes get/put of handle during epoll add/remove.
2019-09-28 15:31:41 +02:00
Dmitrii Kuvaiskii 1645e3435f [LibOS] Allow repeated listen() on the same socket
Typically, listen() is called only once by the application, to mark the
socket as passive for listening for client connections. Thus, LibOS had
a state machine that forbade performing repeated listen() syscalls on
the same socket. However, at least Nginx issues repeated listen's to
adjust the backlog parameter. This commit allows such corner cases.
2019-09-28 15:31:41 +02:00
Simon Gaiser 2d29f7aaeb [Makefile] Drop SGX_RUN
For detection of SGX/non-SGX (for example in regression tests) always
use the SGX environment variable. To generate launch/EINIT tokens use
the new 'sgx-tokens' Make target.
2019-09-27 12:38:14 +02:00
Simon Gaiser 8dd19d28fb [Makefile] Check make clean on Jenkins 2019-09-27 03:45:21 +02:00
Simon Gaiser 13cac1df92 [Makefile] Fix missing cleans 2019-09-27 03:45:21 +02:00
Simon Gaiser d97db4a1e2 [Makefile] Don't include generated dependencies on clean
If we include dependencies in a Makefile for which a target exists
(currently this only affects the manifest.sgx.d targets) then Make will
generate them and then clean will delete them ... so just don't include
them on clean.
2019-09-27 01:33:41 +02:00
Isaku Yamahata 53c7b845f0 [Makefile.rules,Pal/Linux-SGX] Pythonize dependency calculation for SGX manifests 2019-09-26 15:54:45 -07:00
Simon Gaiser 7ce7278121 [Pal/Linux-SGX] Add memory gap around 'exec' area
For this also add the user_address_hole memory range to pal_control.
This is needed to communicate (in a not SGX specific way) the reserved
memory range for the memory gaps around the exec area which can be
inside of the user_address range.
2019-09-26 02:39:03 +02:00
Simon Gaiser 1cb80f23ed [Pal] Add macro for saturated addition/subtraction 2019-09-26 00:42:06 +02:00
Jia Zhang 71638a21cd [Pal/Linux-SGX] pal-sgx-sign: Show signing date 2019-09-26 00:00:58 +02:00
Jia Zhang 82df15eb38 [Pal/Linux-SGX] pal-sgx-sign: Clean up dead code 2019-09-26 00:00:25 +02:00
Jia Zhang 2eea754426 [Pal/Linux-SGX] pal-sgx-get-token: Refactor connecting to aesm service 2019-09-25 15:52:44 -07:00
Jia Zhang 18d0ea23a3 [Pal/Linux-SGX] pal-sgx-get-token: Show signing date 2019-09-25 15:50:13 -07:00
Chia-Che Tsai ee3619df4f [LibOS] test/apps: Rewrite Apache example 2019-09-25 15:03:34 -07:00
borysp 9cd6b34747 [Pal] Change the way argv[0] is handled
Before argv[0] was treated specially and was changed to a value
from manifest file. Now this happens only if binary was run as
a manifest i.e. `./pal_loader path_to_manifest_file`.
2019-09-25 19:16:48 +02:00
Wojtek Porczyk 5e5d783c4c [Doc, Jenkins] Build documentation in Jenkins
Documentation is built as another pipeline to check for build failures.
The result is discarded.
2019-09-25 16:47:51 +02:00
Wojtek Porczyk d3889c3fea [Jenkins] Do not attempt interactive postinstall configuration 2019-09-25 16:46:08 +02:00
Dmitrii Kuvaiskii c10c67840d [LibOS] Makefile.rules: Specify path to pal-symbols via simple assignment
Previously, Makefile.rules specified the absolute path to pal-symbols
file via recursive assignment ("="). However, because Makefile.rules
is included from other Makefiles, this led to incorrect path
("graphene/Pal/src/host/Linux/Pal/src/pal-symbols"). This commit
replaces recursive assignment "=" with simple only-once ":=".
2019-09-24 23:31:46 -07:00
Dmitrii Kuvaiskii 5f106608fa [Pal/Linux] Remove resetting of file offset after fork
Previously, DkReceiveHandle() reset the file offset in the child after
fork(). This is incorrect behavior, since the child must retain the file
offset the same as in the parent. This commit removes the resetting logic.
2019-09-24 20:44:26 -07:00
Dmitrii Kuvaiskii d83330c665 [Pal/Linux] Remove unused pal_handle.file.{pass,append} fields 2019-09-24 20:44:26 -07:00
Dmitrii Kuvaiskii c237bf6bfb [Pal/Linux-SGX] Emulate reads/writes to allowed and trusted files differently
Previously, read()/write() for both trusted and allowed files were
emulated in the same manner: using mmap/memcpy/munmap. This led to
insidious data races in multi-process applications like Apache: one
process would mmap a file and access it during read/write emulation,
while another process would ftruncate the same file (this leads to
SIGBUS as per mmap man page). This happens even for allowed files which
do not require the complicated mmap/memcpy/munmap emulation (this logic
was introduced primarily for trusted-file checksum verification).

This commit separates the emulation of trusted files and allowed files.
The former still use mmap/memcpy/munmap (slightly optimized for
performance), the latter use lseek+read/write (similar to Linux PAL).
This requires new OCALL ocall_lseek(). Also, writing to trusted files
is now explicitly disallowed.
2019-09-24 20:44:26 -07:00
Dmitrii Kuvaiskii c9562d3ead [Pal/Linux-SGX] Remove unused pal_handle.file.{pass,append} fields 2019-09-24 20:44:26 -07:00
Isaku Yamahata 6e3c45c8e3 [Pal/Linux-SGX] pal-sgx-get-token, pal-sgx-sign: move to Python3 and cleanup
This commit rewrites pal-sgx-get-token and pal-sgx-sign in Python3 and
performs a comprehensive cleanup of the code:
- Outputs are sent to separate files (otherwise they were intermixed
  during parallel build)
- aesm_pb2.py is re-generated to Python3
- Numeric constants are replaced with symbolic ones
- Using argparse instead of home-grown argument parsing
- Replacing home-grown helper funcs int_to_bytes(), bytes_to_int(), etc.
  with standard functions
2019-09-24 00:24:26 -07:00
Don Porter 109af04351 [Jenkins] Increase timeout for test_120_8gb_enclave
Our SGX v2 Jenkins workers are inexpensive NUC
computers and need more time to complete the 8GB enclave test.
2019-09-23 13:56:50 -04:00
Don Porter 485accd996 [SGX] Switch from requiring AVX by default to turning it off by default. 2019-09-23 12:01:37 -04:00
Dmitrii Kuvaiskii b3d00dc647 [Pal/Linux-SGX] Allow to write/send from buffer in untrusted memory
Previously, ocall_write() and ocall_sock_send() disallowed to write/send
data from a buffer allocated in untrusted memory (as it was considered
an impossible scenario). However, sendfile() logic may write an allowed
regular file (which is mmapped in untrusted memory) directly to a socket.
Thus, this commit allows such writes/sends.
2019-09-18 17:14:12 -07:00
Dmitrii Kuvaiskii 57d9e3347d [LibOS] Fix typo in handle_copy() which led to failed sendfile() 2019-09-18 17:14:12 -07:00
Dmitrii Kuvaiskii 4279c7e063 [Pal/Linux-SGX] Fix OCALLs returning EPERM when recv returns 0
Previously, ocall_sock_recv() and ocall_sock_recv_fd() had a bug exposed
when the underlying host recv/recvmsg syscall returned 0. Return value
of 0 led to sgx_copy_to_enclave() to also return 0 which is treated as
EPERM error. This commit omits calls to sgx_copy_to_enclave() when
return value is 0 (since there is nothing to copy anyway).
2019-09-18 16:21:11 -07:00
Dmitrii Kuvaiskii 07f0e25ff2 [LibOS] shim_parser.c: Additionally specify string as "const char*"
The parser logic checks the arguments of syscalls and prints strings in
debug output. Previously, our code base only contained "const char *" as
strings. Recently, we started migration to "const char*" (no-space) style.
This broke the parser logic, so this commit adds an additional check on
what it means for a C type to be a string.
2019-09-18 15:36:11 -07:00