Commit Graph
165 Commits
Author SHA1 Message Date
smherwig 5c42c026c6 [LibOS] Ignore POLLERR and POLLHUP in events in poll()
See #389.

Per the manpage, POLLERR and POLLUP are returned in `revents` and
ignored in `events`.  Indeed, programs should not be setting, and
typically don't set -- `events` with these values.

The effect of this bug is, among others, that a process will never get a
disconnect event from a peer socket.
2019-05-03 03:36:14 +02:00
Chia-Che Tsai 09ad502c3a [LibOS] Use the C11 standard instead of GNU99 2019-05-01 20:43:04 -05:00
Don Porter e62a021fd8 Add an open method to /proc and some subdirectories
This addresses issue #461.
2019-05-01 09:04:51 -04:00
Isaku Yamahata 8890b325b4 [Pal, LibOS] Clear RFLAGS on program entry
SYSV x86-64 ABI requires RFLAGS to be cleared in initial register state.
2019-05-01 13:21:30 +02:00
Isaku Yamahata f72cd48ee5 [LibOS] Emulate pause() by sleeping for a very long time
Before, pause() was emulated by sleeping for 1s in a loop until
signal interrupted it. If signal arrived in-between these invocations
then pause() could never return. Also, pause() incorrectly returned 0
instead of -1 and errno=EINTR.

This patch emulates pause() by sleeping for a very long time (years).
Also, it correctly returns EINTR.
2019-04-30 17:07:51 -07:00
Michał Kowalczyk 382a1ec394 Cleanup .gitignore files 2019-04-30 23:16:38 +02:00
Michał Kowalczyk 17102eab9d Change DkRandomBitsRead interface and fix error checking
Now it returns 0 on success and -PAL_* on error.
2019-04-30 22:26:08 +02:00
Michał Kowalczyk 57749eb973 [LibOS] Don't use insecure random 2019-04-30 22:23:04 +02:00
Isaku Yamahata ec4a3f7bb5 [LibOS] Emulate clone(CLONE_VFORK | CLONE_VM | SIGCHLD) as vfork()
Some runtimes use clone(CLONE_VFORK | CLONE_VM | SIGCHLD) for vfork().
2019-04-30 15:45:37 +02:00
Isaku Yamahata 86897c7049 [LibOS] Align stack on 16B during user executable start
x86-64 ABI requires 16B alignment of stack on function calls.
To conform to ABI, align stack when jumping to the entry point
of the user executable.
2019-04-29 15:28:22 -07:00
Simon Gaiser 402fce72ba Autogenerate offsets for Python
This makes the offset generator more generic to generate a python module
in addition to a header for assembly.
2019-04-29 21:30:09 +02:00
Isaku Yamahata 10994e1b69 [Makefile] Use symlinks instead of cp to populate Runtime dir
Currently cp to Runtime dir is used. Sometimes it is confusing when
binaries are re-built under Pal or LibOS. Symlink is better, so use
it instead.
  - It's easy to understand where a file under Runtime dir comes from
  - It's easy to understand in which directory to run `make`
  - If cp is used, it's quite easy to test old binary under Runtime.

This patch create ln_sf rule and use it instead of cp and applies to
other recipe with cp.
In this context, creating symlink of glibc libraries is mess. This
patch also cleans it up to use Makefile instead of embedding the logic
into python script.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-26 02:47:38 +02:00
Isaku Yamahata 315c7b60ff [LibOS] Use static inline function instead of C macro 2019-04-25 19:18:54 +02:00
Isaku Yamahata 07c5daab74 [LibOS] Remove unused struct un_conn in shim_socket.c 2019-04-25 01:00:04 -07:00
Isaku Yamahata c7296d2512 [LibOS] Set clear_child_tid value for the calling thread on set_tid_address() 2019-04-23 16:04:26 -07:00
Isaku Yamahata 19fa7b04cd [LibOS] Fix buffer overflow in debug_fputch
When debug buf reached to the end, it should be reset to the start after
output.
This can happen with
debug_printf("%s",
"string-without-newline-longer-than-debug_buf-DEBUGBUF_SIZE=255"...);

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-17 00:48:00 +02:00
Rafał Wojdyła d362b2969b [LibOS] Correctly set type of directory entries
Fixes #531
2019-04-15 19:34:33 -04:00
Isaku Yamahata 745ab4a478 [Pal/Linux-SGX] Generate asm offsets and use them
This patch auto-generates asm offsets for Pal/Linux-SGX and uses them.
Also to share the generation logic among Pal and LibOS, header file for
it is created under Pal.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-13 00:54:12 +02:00
Rafał Wojdyła 4e12964dbd [LibOS] Fix handle leak in shim_do_munmap() 2019-04-12 18:05:30 +02:00
Rafał Wojdyła b46496a379 Fix free() to accept NULL pointers 2019-04-12 18:05:30 +02:00
Rafał Wojdyła e37d29fee0 Remove duplicate semicolon 2019-04-12 18:05:30 +02:00
Isaku Yamahata e568ded00e [LibOS] start.S: remove unnecessary movq
callq can take memory address directly.
it's unnecessary to load the address to register.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-12 16:57:30 +02:00
Isaku Yamahata 08d0866850 [LibOS] syscallas.S: Reference shim_table through GOT
libsysdb.so is compiled as pic.
2019-04-10 23:16:06 +02:00
Isaku Yamahata 9c398764ce [LibOS] shim_thread.h/shim_tls.h: use static inline instead of macro
Macros are used unnecessarily. Use static inline functions instead.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-09 01:49:29 +02:00
Isaku Yamahata 7535273ecc [LibOS] Add checks for printf format
This patch adds printf format check and fixes most of found issues.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-07 15:12:28 +02:00
Isaku Yamahata 4039813623 [LibOS] code clean up of shim_signal.c
this patch cleans up shim_signal.c without logic change.
- remove unnecessary goto
  In this file, goto is abused unnecessarily.
- remove unnecessary macro
  Two macros, is_internal, internal_fault can be inline function.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-04 16:26:42 -04:00
Zhang Chen 06b71fc1a0 [LibOS] shim_namei.c: Fix input absolute path error and add test case
This bug just occurs when reading a symlink on procfs.
If input is an absolute path, it will get wrong my_dent.
So we use stat syscall to check whether the "/proc/1/root"
and "/" is same path in graphene.

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
2019-04-04 08:29:41 -04:00
Li Lei 195c2b1f7b [PAL] Enable Wunsed-parameter warning as part of Wextra 2019-04-03 14:27:43 +02:00
Don Porter a5471a80a8 Fix the large-mmap test. 2019-04-02 14:55:15 -04:00
Isaku Yamahata 8c65f67a65 [LibOS] signal: wakeup thread on append_signal
There are race condition on thread_sleep() and DkThreadResume().
To avoid it, wake up the thread.
test program is can be found at
https://github.com/oscarlab/graphene/pull/452.
NOTE: there are still other race conditions. this patch
only address one of them.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-01 11:22:00 -04:00
Isaku Yamahata ceb7897320 [LibOS] use struct debug_buf instead of void * in shim_tcb_t
Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-03-29 09:51:07 -04:00
Isaku Yamahata 4a2257d413 [shim, Pal/Linux-SGX]: don't use -e for ld, but use ENTRY
Use ENTRY in linker script, shim.lds and enclave.lds, instead of -e for
ld command line in Makefile.
This also helps to understand how link is done. only shim.lds/enclave.lds
need to be read. don't have to dig into Makefile for command line.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-03-26 07:54:42 -04:00
Isaku Yamahata 38ac39810e [Makefile] add targets for .i and .s
For prepossessed file, .i for .c and .s for .S are commonly used.
not .e.
This patch adds rules to produce .i/.s file in addition to .e.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-03-25 15:19:19 -04:00
Isaku Yamahata 4b190baef7 [LibOS] asm offset constants generation
Auto generate offset constants for assembly. replace magic number with
symbolic constants in LibOS/shim/src/syscallas.S.

This patch also introduces Makefile.rules to accommodate common make rules
so that V=1 (like Linux style make) is accepted.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-03-25 14:54:51 +01:00
Isaku Yamahata fb48d0e388 [LibOS] shim_checkpoint.c: retry DkStreamRead/DkStreamWrite
On EINTR/EAGAIN (and for EWOULDBLOCK for portability) of
DkStreaRead/DkStreamWrite, retry the PAL call instead of error out.
Especially when it runs under debugger, EINTR often happens.
This patch makes debug easier.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-03-19 15:45:30 +01:00
Michał Kowalczyk 8346868dfc [PAL] Rename PAL_EVENT_DIVZERO to PAL_EVENT_ARITHMETIC_ERROR 2019-03-14 00:39:23 +01:00
Gary 5d799d27f9 Fix null test and write test issues about the stat parameter
This issue may cause SegFault if pass null to state,
and miss the validation by test_user_memory(...) if not null.
2019-02-27 14:42:34 -05:00
Zhang Chen aed520f977 [LibOS] Fix code style issues in install_async_event()
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
2019-02-27 12:46:48 -05:00
Zhang Chen 535c2d78df [LibOS] shim_futex.c:Remove duplicate codes in FUTEX_WAIT_BITSET
No need to check futex_op twice when FUTEX_WAIT_BITSET.

Signed-off-by: Zhang Chen <chen.zhang@intel.com>
2019-02-25 13:39:03 -05:00
Gary 54f767f7ba [LibOS] Fix the storage of local_objects leaks in shim_async_helper
before DkThreadExit(), allocated resource local_objects were not freed, causing resource leakage of local_objects content

Signed-off-by: Gary <gang1.wang@intel.com>
2019-02-21 11:59:32 -05:00
Isaku Yamahata b44d8335a1 [LibOS] fix futex signature
Futex word is int, not unsigned int.
So it should use int * instead of unsigned int *.
Also add fallthrough directive for lint to eliminate warning.
I believe fallthrough of switch clause is intentional, not bug.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-02-20 12:05:21 -05:00
Thomas Knauth 58bd20e8d3 [LibOS] Explicitly return error if flags parameter set for recvmsg/recvmmsg/recvfrom 2019-02-20 12:04:01 -05:00
Isaku Yamahata 6d50e6cdef [LibOS] Zero %rdx on entry of user program
As x86-64 unix ABI, %rdx on user program entry is a function pointer
which is registered as atexit. It should be zeroed unless LibOS needs
it. Otherwise random %rdx as function pointer is called by atexit and
can result in error. typically SEGV.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-02-19 14:33:39 -05:00
Don Porter a1fb373e98 Set the correct file type (regular file) for /proc/cpuinfo and /proc/meminfo. This addresses issue #308 2019-02-19 10:33:09 -05:00
Isaku Yamahata e7c7c3c194 [shim/src/Makefile] Remove build files (libsyscalldb.*) on make clean 2019-02-18 18:47:04 +01:00
Gary 6a09032f2d [LibOS] Simplify condition expression
`polls + npolls` is less confusing and simpler than `&polls[npolls]`.

Signed-off-by: Gary <gang1.wang@intel.com>
2019-02-18 11:39:02 -05:00
Isaku Yamahata 9aebe3c0f8 [LibOS] remove unnecessary __alloca()
remove abuse of __alloca() with normal variable on stack.
This patch cleans up abuse of __alloca().

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-02-15 19:43:08 -05:00
Zhang Chen f8059d338b [LibOS] Variable len is used without initilization
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
2019-02-15 18:25:29 -05:00
Gary 115edbf2fa [LibOS] Fix uninitialized value new_shargs.first
new_shargs used without initialization, could cause undefined behaviors as its contents are passed to other variables

Signed-off-by: Gary <gang1.wang@intel.com>
2019-02-15 19:41:28 +01:00
Gary ddd4e3d20d [LibOS] Fix a memory leak in __map_elf_object() about variable pointer new_phdr
new_phdr is allocated using malloc, if failed, it may cause unpredictable behavior on read operation,
also causing resource leakage of new_phdr if read operation failed.

Signed-off-by: Gary <gang1.wang@intel.com>
2019-02-15 18:59:44 +01:00