Commit Graph
21 Commits
Author SHA1 Message Date
Stefan Berger c0163a6036 [Pal] Move x86_64-specific atomic.h to Pal/include/lib/x86_64
Also, adapt the Makefiles to include the new directory in CFLAGS.
2020-05-09 14:43:17 +02:00
borysp c9742cb9cd Add READ_ONCE and WRITE_ONCE macros
Sometimes we need to prevent the compiler from reading or writing to
a memory location twice to prevent certain TOCTOU bugs. This can now
be achieved by using the introduced macros and this commit does so in
enclave_ocalls.c for Linux-SGX.
2020-05-08 01:43:12 +02:00
borysp 6cb111b6d1 [LibOS] Completely rework LibOS VMA bookkeeping
This commit completely reworks VMA subsystem along with its usages.
New version should be: cleaner (easier to maintain), faster and allow
for bookkeeping requests from Pal.
It also fixes some bugs and inconsistencies found in the process and
changes brk and mmap/munmap implementations (at least partially).
2020-05-02 16:22:00 +02:00
Michał Kowalczyk 5e2eee0086 [Pal] Remove likely/unlikely macros 2020-04-20 22:00:58 +02:00
Dmitrii Kuvaiskii 8d9f9f567f [Pal/Linux-SGX] Put TLS-context init logic in critical section
mbedTLS configuration used in Graphene is not thread-safe (because
this would require the use of a threading library like pthread which
is not possible in the LibOS/Pal layers). However, some mbedTLS
functions use shared state, in particular TLS context initialization
functions. This led to data races during encrypted-pipe creation,
since it requires two threads performing a TLS handshake. This commit
refactors TLS init into SSLInit (not thread-safe) and SSLHandshake
(thread-safe) and adds spinlocks around SSLInit to protect the racy
mbedTLS logic.
2020-04-17 01:30:00 -07:00
borysp bbc2387d76 [Pal/lib] Add missing root node update to avl_tree_swap_node 2020-04-15 12:20:29 +02:00
Dmitrii Kuvaiskii caf1263070 [Pal/Linux-SGX] Encrypt all pipes/socketpairs with TLS-PSK
Previously, Linux-SGX PAL did not encrypt pipe/socketpair
communication (only process checkpoint send/receive was encrypted).
This commit encrypts all pipe/socketpair IPC between threads of
the same enclave and between enclave processes. In particular, all
offsprings of the "first" enclave inherit the same master key and
derive IPC session keys from this master key based on pipe name.
When two pipe/socketpair endpoints are first created, they establish
a TLS-PSK session via intra-enclave handshake (requires a spawn of
an intermediate enclave thread). During clone/fork/exec, endpoints'
TLS contexts are serialized and sent to the child that deserializes
them (using mbedtls_ssl_context_{save,load} functions).

Note that multicast pipes (with more than two communicating entities)
are not supported since TLS protocol doesn't support it.

This commit modifies the PAL `SendHandle` test to correctly test
pipe communication, as well as adds the LibOS `pipe` test.
2020-04-13 16:18:58 -07:00
Michał Kowalczyk 2b4e50c9bb [LibOS] Clean up PAUSE macros 2020-04-10 19:23:42 -07:00
Dmitrii Kuvaiskii 7e20a8044c [LibOS,Pal] Replace 32-bit pipeid with 256-bit pipe name
Previously, Graphene used the notation "pipe:<uint32_t>" to emulate
pipes, socketpairs, and UNIX domain sockets. In particular, pipes
and socketpairs received random integer IDs, and sockets received
deterministic integer IDs. However, 32-bit randomly generated IDs
may collide quite often. Since pipe IDs/names should *not* repeat
(otherwise e.g. derived crypto keys will be reused), this commit
changes pipe IDs (pipeid) from uint32_t to char[96], and pipe IDs
(names) become 256-bit random sequences.
2020-04-10 17:39:11 -07:00
borysp bf6be81310 [Pal/lib] Add avl_tree_first and avl_tree_last 2020-04-10 23:11:01 +02:00
Michał Kowalczyk e58933a971 [Pal/lib] Simplify static_str* macros 2020-04-02 01:46:48 +02:00
Michał Kowalczyk 727c2ab049 Fix typos 2020-04-02 01:46:48 +02:00
borysp 5f1e6ca317 [Pal/lib] Add generic trees (AVL) 2020-04-01 02:46:33 +02:00
borysp 6fd54058d5 [LibOS] Disable signals in critical section in shim_futex.c 2020-04-01 01:01:54 +02:00
Dmitrii Kuvaiskii c43214523c [Pal/lib] spinlock.h: Add features for our own mutex implementation
Our implementation of mutexes for Exitless Syscalls requires three-state
spinlocks and spinlocks with timeouts (see Futexes are Tricky).
2020-03-24 00:34:45 -07:00
Dmitrii Kuvaiskii 8d76f9d3fb [Pal/Linux-SGX] Remove remote attestation functionality
Previously, Graphene with SGX performed self-remote attestation
by retrieving the SGX quote from the Quoting Enclave, sending it
to the Intel Attestation Service via Curl (in an HTTPS request),
and parsing the received from IAS remote-attestation certificate.

This self-attestation functionality is meaningless and is removed.
Moreover, since EPID-based remote attestation requires client key
(Ocp-Apim-Subscription-Key), and this key must be kept secret,
specifying it in the Graphene manifest (as was done previously) is
insecure. Therefore, the whole remote attestation functionality is
moved out of Graphene and to another trusted party (or to the app
on top of Graphene). Only the SGX quote retrieval from the Quoting
Enclave is kept in Graphene.
2020-03-19 18:08:37 +00:00
Dmitrii Kuvaiskii 95bfd8aeb5 [Pal/Linux-SGX] Refactor memory management of enclave pages
Previously, Linux-SGX logic of allocating/freeing enclave pages was
complicated and hard to read. This commit refactors this code for
readability, without changes in functionality.
2020-03-04 08:41:28 -08:00
Isaku Yamahata 551b32a036 [Pal/Linux-SGX] Fix ocall_{read,write,recv,send} to return ssize_t
Also, all users of these OCALLs are modified to operate on ssize_t
return values, including LIB_SSL_CONTEXT/mbedTLS callbacks.
2020-03-02 17:36:07 -08:00
borysp b40862a59c [LibOS,Pal/{Linux, Linux-SGX}] Add bogomips to /proc/cpuinfo 2020-03-02 21:48:55 +01:00
Isaku Yamahata 1738f698e7 [Pal/lib] Fix slabmgr initialization
STARTUP_SIZE constant was used (incorrectly) instead of alignment-aware
`size`.
2020-02-16 17:58:26 +01:00
Isaku Yamahata 0a7e3dd127 [LibOS,Pal] Move header files from Pal/lib/ under Pal/include/ 2020-02-05 23:21:06 -08:00