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.
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.
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
before DkThreadExit(), allocated resource local_objects were not freed, causing resource leakage of local_objects content
Signed-off-by: Gary <gang1.wang@intel.com>
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>
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>
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>
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>
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>