Commit Graph
317 Commits
Author SHA1 Message Date
Gary e0506e43aa [LibOS] Prevent memory leak during read_environs()
During initialization, LibOS parses the LD_PRELOAD environment variable
and allocates memory to store its entries. On error, this allocated
memory must be freed. This commit correctly frees memory on error.
2019-05-08 17:02:14 -07:00
Isaku Yamahata 6d31302e35 [LibOS] Fix sched_getaffinity to return byte size, not bit size
Fixes the following bugs:
* sched_getaffinity(2) should return # of bytes, not bits.
* It should honor `len` argument.
* Linux sched_getaffinity() aligns the result to sizeof(long).
2019-05-08 13:37:20 +02:00
Biao Lu 2c87e294fc [LibOS] Make /proc/cpuinfo output exactly like in Linux kernel
Some Linux applications get the number of CPU cores by querying
/proc/cpuinfo.  Before, such apps would be confused by a wrong
format of /proc/cpuinfo in Graphene. This commit updates format
to exactly the same as in Linux kernel.

This commit also adds a LibOS regression test for /proc/cpuinfo.
2019-05-07 18:59:37 -07:00
Isaku Yamahata b7907fa83d [LibOS] Make clone ABI match kernel and update glibc patch
glibc: remove unnecessary pushq/popq so that shim_clone can run without segv.
This is a preparation for later patch to clean up shim_clone() to
remove glibc modification.
libos: Currently child thread ret ip is taken from new child stack.
But it can be retrieved from parent's thread context, so such a hack
isn't needed.
Now the modification to clone.S is not needed anymore. So remove it.
2019-05-08 02:04:33 +02:00
Michał Kowalczyk 2bc2c04194 Remove trailing blanks 2019-05-07 16:32:16 +02:00
Isaku Yamahata 783304de6a [LibOS] Preserve rflags register on syscalldb()
Linux system calls preserve rflags; LibOS must do the same.
This commit adds rflags to shim_regs and saves/restores it
on syscalldb() entry/exit.
2019-05-07 00:31:31 -07:00
Michał Kowalczyk 281a05ce48 Fix camel case in DkStreamAttributes{Query,Set}ByHandle 2019-05-06 18:11:15 -07:00
Dmitrii Kuvaiskii f420037285 [LibOS] Remove unused errval from __map_elf_object() 2019-05-06 16:01:35 -07:00
Gary d19b266ed4 [LibOS] Fix memory leak in __map_elf_object()
Pointer l can point to a newly allocated object (via new_elf_object()).
Ensure l is freed on error (on call_lose code path).
2019-05-06 16:01:35 -07:00
Dmitrii Kuvaiskii 402020f8da [LibOS/regression] Add futex-timeout test
Before PR #554, futex() syscall incorrectly failed
if user-supplied timeout expired (also see PR #438).
This patch adds test on futex() with timeout.
2019-05-06 13:46:26 -07:00
Michał Kowalczyk d7b3d6074a Align stack to 16 when calling C from asm 2019-05-04 14:16:21 +02:00
Isaku Yamahata 0a8f97af5a [Pal/{Linux, Linux-SGX}] Add NULL check in udp_connect/sgx_ocall_sock_connect
This patch also adds a UDP LibOS regression test.
2019-05-03 12:50:03 -07:00
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
Dmitrii Kuvaiskii bd72b968ee [*/regression] Increase timeout of regression tests
On weaker machines (Intel NUCs and SGX-enabled laptops),
SGX regression tests take longer than 5 seconds because
Graphene measures/zeroes all enclave memory at startup.
Increase the timeout for SGX regression tests to 20 sec.
2019-04-29 18:10:32 -07: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 9f61dc2871 [LibOS/test/ltp] Skip make autotools for LTP
Running "make autotools" is not required when building it from the
tarball (it already includes necessary pre-built autotools stuff).
2019-04-27 13:31:53 +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 8975d87338 [LibOS] glibc-2.19.patch: Remove _dl_debug_state renaming
_dl_debug_state has hidden visibility, so there is no risk in using it
with Pal. We can remove the modification to glibc and rename
__libc_dl_debug_state back to _dl_debug_state.
2019-04-25 12:22:49 +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 0fe0e028d8 [LibOS/test/native] Add manifest template to make exec_fork and script work + fix tcp test
`tcp` test reads tcp.c. This patch adds it to manifest.template to make the test work.
2019-04-24 17:37:31 +02: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
Simon Gaiser f30f7e7575 [*/regression] Use uniform and cleaner SGX environment check
As suggested by @yamahata in PR #612.
2019-04-17 02:08:37 +02: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 f859f3da77 [LibOS] Add regression test for getdents 2019-04-15 19:34:33 -04:00
Rafał Wojdyła d362b2969b [LibOS] Correctly set type of directory entries
Fixes #531
2019-04-15 19:34:33 -04:00
Simon Gaiser 79d6fb27ec [*/regression] Migrate to Python 3 2019-04-15 17:27:30 +02:00
Simon Gaiser 3d60004a8c [*/regression] Drop unused shebang
The regression python scripts are not marked executable. Also they
expect that the Makefile has setup the environment correctly so just
marking them executable would not be useful. So drop the unused shebang
to avoid encoding the interpreter in multiple places.

Script/regression.py is a library so it also doesn't need a shebang.
2019-04-15 17:24:27 +02: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 5243cf1d95 [LibOS] glibc-2.19/syscalldb.h: use callq indirect call with memory
indirect call of memory value is usable. So we don't have to
load pointer value for callq.

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
2019-04-09 21:21:26 +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
Zhang Chen 5cd91c596c [LibOS] Add missed error handling and fix codestyle issues in epoll_wait regression test
Signed-off-by: Zhang Chen <chen.zhang@intel.com>
2019-04-03 16:39:00 +02:00
Li Lei 195c2b1f7b [PAL] Enable Wunsed-parameter warning as part of Wextra 2019-04-03 14:27:43 +02:00