Skip to content
This repository was archived by the owner on Jan 20, 2022. It is now read-only.

Commit 1a1e199

Browse files
committed
release v0.4beta
Release of Graphene SGX: Supporting native Linux application in Intel SGX enclaves. Most applications are supported. Some features may still be buggy. Improving portability of Graphene: Eliminating GCC-ism of the host-generic code. Easier to port to non-Posix platform (e.g., Windows without Cygwin).
1 parent f06d435 commit 1a1e199

File tree

281 files changed

+26882
-3983
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

281 files changed

+26882
-3983
lines changed

LibOS/.packed/glibc.sha384

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
build/crt1.o build/crti.o build/crtn.o build/ld-linux-x86-64.so.2 build/libc.so.6 build/libdl.so.2 build/liblibos.so.1 build/libm.so.6 build/libpthread.so.0 build/libutil.so.1
1+
glibc-build/crt1.o glibc-build/crti.o glibc-build/crtn.o glibc-build/ld-linux-x86-64.so.2 glibc-build/libc.so.6 glibc-build/libdl.so.2 glibc-build/liblibos.so.1 glibc-build/libm.so.6 glibc-build/libpthread.so.0 glibc-build/libutil.so.1

LibOS/.packed/glibc.tar.gz

-2.36 KB
Binary file not shown.

LibOS/Makefile

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
SYS ?= $(shell gcc -dumpmachine)
22
export SYS
33

4+
export DEBUG
5+
46
GLIBC_SRC = glibc-2.19
57
SHIM_DIR = shim
6-
BUILD_DIR = build
8+
BUILD_DIR = glibc-build
79
GLIBC_TARGET = $(addprefix $(BUILD_DIR)/,libc.so.6 ld-linux-x86-64.so.2 libpthread.so.0 libm.so.6 libdl.so.2 libutil.so.1 crt1.o crti.o crtn.o liblibos.so.1)
810

911
all: $(GLIBC_TARGET)
1012
$(MAKE) -C $(SHIM_DIR) all
1113

12-
debug: DEBUG=debug
13-
debug: $(GLIBC_TARGET)
14-
$(MAKE) -C $(SHIM_DIR) debug
15-
1614
install:
1715
[ -d ../Runtime ] || mkdir -p ../Runtime
1816
[ -f ../Runtime/libsysdb.so ] || ln -sf ../LibOS/shim/src/libsysdb.so ../Runtime/libsysdb.so
@@ -23,7 +21,11 @@ $(GLIBC_TARGET): $(BUILD_DIR)/Makefile
2321
cd $(BUILD_DIR) && $(MAKE)
2422

2523
$(BUILD_DIR)/Makefile: $(GLIBC_SRC)/configure
26-
./buildglibc.py --quiet $(DEBUG)
24+
ifeq ($(DEBUG),1)
25+
./buildglibc.py --quiet --debug
26+
else
27+
./buildglibc.py --quiet
28+
endif
2729

2830
$(GLIBC_SRC)/configure:
2931
[ -f $(GLIBC_SRC).tar.gz ] || \

LibOS/buildglibc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def appendText(filename, text) :
2727
glibc = "glibc-2.19"
2828
glibcParent = "" # glibc parent directory
2929
glibcDir = "" # glibc dir (ex. glibc-2.19)
30-
buildDir = "build"
30+
buildDir = "glibc-build"
3131
installDir = os.path.dirname(home) + '/Runtime/'
3232
do_install = False
3333
commandStr = ""
@@ -38,7 +38,7 @@ def appendText(filename, text) :
3838
for arg in sys.argv[1:]:
3939
if arg == '--quiet' or arg == '-q':
4040
quiet = True
41-
if arg == 'debug':
41+
if arg == '--debug':
4242
debug_flags = "-g"
4343
if arg == 'install':
4444
do_install = True

LibOS/shim/src/.packed/shim.sha384

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
bookkeep/shim_handle.o bookkeep/shim_signal.o bookkeep/shim_thread.o bookkeep/shim_vma.o elf/shim_rtld.o fs/chroot/fs.o fs/dev/fs.o fs/pipe/fs.o fs/proc/fs.o fs/proc/info.o fs/proc/ipc-thread.o fs/proc/thread.o fs/shim_dcache.o fs/shim_fs_hash.o fs/shim_fs.o fs/shim_namei.o fs/socket/fs.o fs/str/fs.o ipc/shim_ipc_child.o ipc/shim_ipc_helper.o ipc/shim_ipc.o ipc/shim_ipc_pid.o ipc/shim_ipc_sysv.o libsysdb.a libsysdb_debug.so libsysdb.so shim_async.o shim_checkpoint.o shim_debug.o shim_init.o shim_malloc.o shim_parser.o shim_random.o shim_syscalls.o shim_table.o start.o syscallas.o sys/shim_access.o sys/shim_alarm.o sys/shim_benchmark.o sys/shim_brk.o sys/shim_clone.o sys/shim_dup.o sys/shim_epoll.o sys/shim_exec.o sys/shim_exit.o sys/shim_fcntl.o sys/shim_fork.o sys/shim_fs.o sys/shim_futex.o sys/shim_getcwd.o sys/shim_getpid.o sys/shim_getrlimit.o sys/shim_ioctl.o sys/shim_migrate.o sys/shim_mmap.o sys/shim_msgget.o sys/shim_open.o sys/shim_pipe.o sys/shim_poll.o sys/shim_sandbox.o sys/shim_sched.o sys/shim_semget.o sys/shim_sigaction.o sys/shim_sleep.o sys/shim_socket.o sys/shim_stat.o sys/shim_time.o sys/shim_uname.o sys/shim_vfork.o sys/shim_wait.o sys/shim_wrappers.o utils/md5.o utils/printf.o utils/strobjs.o 83034d6b1a614018afb9f84143540b32f186d868019d4d40844ef972deb7aaaf05ad2d81c9c35932d3dd98a37b75079f
1+
bookkeep/shim_handle.o bookkeep/shim_signal.o bookkeep/shim_thread.o bookkeep/shim_vma.o elf/shim_rtld.o fs/chroot/fs.o fs/dev/fs.o fs/pipe/fs.o fs/proc/fs.o fs/proc/info.o fs/proc/ipc-thread.o fs/proc/thread.o fs/shim_dcache.o fs/shim_fs_hash.o fs/shim_fs.o fs/shim_namei.o fs/socket/fs.o fs/str/fs.o ipc/shim_ipc_child.o ipc/shim_ipc_helper.o ipc/shim_ipc.o ipc/shim_ipc_pid.o ipc/shim_ipc_sysv.o libsysdb.a libsysdb_debug.so libsysdb.so shim_async.o shim_checkpoint.o shim_debug.o shim_init.o shim_malloc.o shim_parser.o shim_random.o shim_syscalls.o shim_table.o start.o syscallas.o sys/shim_access.o sys/shim_alarm.o sys/shim_benchmark.o sys/shim_brk.o sys/shim_clone.o sys/shim_dup.o sys/shim_epoll.o sys/shim_exec.o sys/shim_exit.o sys/shim_fcntl.o sys/shim_fork.o sys/shim_fs.o sys/shim_futex.o sys/shim_getcwd.o sys/shim_getpid.o sys/shim_getrlimit.o sys/shim_ioctl.o sys/shim_migrate.o sys/shim_mmap.o sys/shim_msgget.o sys/shim_open.o sys/shim_pipe.o sys/shim_poll.o sys/shim_sandbox.o sys/shim_sched.o sys/shim_semget.o sys/shim_sigaction.o sys/shim_sleep.o sys/shim_socket.o sys/shim_stat.o sys/shim_time.o sys/shim_uname.o sys/shim_vfork.o sys/shim_wait.o sys/shim_wrappers.o utils/md5.o utils/printf.o utils/strobjs.o 1e360b5c25155fe56c120120f88f25eec00ff96007893eceafd124a56de5e12dcf3e63852b58221cd289daf93e8d4cd3

LibOS/shim/src/.packed/shim.tar.gz

-14.6 MB
Binary file not shown.

LibOS/shim/src/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ headers = ../include/*.h ../../../Pal/lib/*.h ../../../Pal/include/pal/*.h
4848

4949
all: $(shim_target)
5050

51-
debug: debug = debug
52-
debug: CC = gcc -gdwarf-2 -g3
53-
debug: CFLAGS += -DDEBUG
54-
debug: $(shim_target)
51+
ifeq ($(DEBUG),1)
52+
CC += -gdwarf-2 -g3
53+
CFLAGS += -DDEBUG
54+
endif
55+
export DEBUG
5556

5657
ifeq ($(PROFILING), 1)
5758
CFLAGS += -DPROFILE

LibOS/shim/src/bookkeep/shim_signal.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ static void quit_upcall (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
306306
DkExceptionReturn(event);
307307
}
308308

309-
bool ask_for_checkpoint = false;
310-
311309
static void suspend_upcall (PAL_PTR event, PAL_NUM arg, PAL_CONTEXT * context)
312310
{
313311
if (IS_INTERNAL_TID(get_cur_tid()))

LibOS/shim/src/bookkeep/shim_vma.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,8 @@ BEGIN_RS_FUNC(vma)
11671167

11681168
unlock(vma_list_lock);
11691169

1170-
debug ("vma: %p-%p flags %x prot %p\n", vma->addr, vma->addr +
1171-
vma->length, vma->flags, vma->prot);
1170+
debug("vma: %p-%p flags %x prot %p\n", vma->addr, vma->addr + vma->length,
1171+
vma->flags, vma->prot);
11721172

11731173
if (!(vma->flags & VMA_UNMAPPED)) {
11741174
if (vma->file) {

LibOS/shim/src/fs/chroot/fs.c

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ static int chroot_mount (const char * uri, const char * root,
6767
{
6868
enum shim_file_type type;
6969

70-
if (!memcmp(uri, "file:", 5)) {
70+
if (strpartcmp_static(uri, "file:")) {
7171
type = FILE_UNKNOWN;
7272
uri += 5;
73-
} else if (!memcmp(uri, "dev:", 4)) {
74-
type = memcmp(uri + 4, "tty", 3) ? FILE_DEV : FILE_TTY;
73+
} else if (strpartcmp_static(uri, "dev:")) {
74+
type = strpartcmp_static(uri + static_strlen("dev"), "tty") ?
75+
FILE_DEV : FILE_TTY;
7576
uri += 4;
7677
} else
7778
return -EINVAL;
@@ -104,48 +105,42 @@ static inline int concat_uri (char * buffer, int size, int type,
104105
const char * root, int root_len,
105106
const char * trim, int trim_len)
106107
{
107-
int len = 0;
108+
char * tmp = NULL;
108109

109110
switch (type) {
110111
case FILE_UNKNOWN:
111112
case FILE_REGULAR:
112-
if (size < 7 + root_len + trim_len)
113-
return -ENAMETOOLONG;
114-
memcpy(buffer, "file:", 6);
115-
len += 5;
113+
tmp = strcpy_static(buffer, "file:", size);
116114
break;
117115

118116
case FILE_DIR:
119-
if (size < 6 + root_len + trim_len)
120-
return -ENAMETOOLONG;
121-
memcpy(buffer, "dir:", 5);
122-
len += 4;
117+
tmp = strcpy_static(buffer, "dir:", size);
123118
break;
124119

125120
case FILE_DEV:
126121
case FILE_TTY:
127-
if (size < 6 + root_len + trim_len)
128-
return -ENAMETOOLONG;
129-
memcpy(buffer, "dev:", 5);
130-
len += 4;
122+
tmp = strcpy_static(buffer, "dev:", size);
131123
break;
132124

133125
default:
134126
return -EINVAL;
135127
}
136128

129+
if (!tmp || tmp + root_len + trim_len + 2 > buffer + size)
130+
return -ENAMETOOLONG;
131+
137132
if (root_len) {
138-
memcpy(buffer + len, root, root_len + 1);
139-
len += root_len;
133+
memcpy(tmp, root, root_len + 1);
134+
tmp += root_len;
140135
}
141136

142137
if (trim_len) {
143-
buffer[len++] = '/';
144-
memcpy(buffer + len, trim, trim_len + 1);
145-
len += trim_len;
138+
*(tmp++) = '/';
139+
memcpy(tmp, trim, trim_len + 1);
140+
tmp += trim_len;
146141
}
147142

148-
return len;
143+
return tmp - buffer;
149144
}
150145

151146
/* simply just create data, sometimes it is individually called when the
@@ -672,7 +667,7 @@ static int map_write (struct shim_handle * hdl, const void * buf,
672667
if (file->marker + count > file->size) {
673668
file->size = file->marker + count;
674669

675-
ret = DkStreamWrite(hdl->pal_handle, file->marker, count, buf, NULL);
670+
ret = DkStreamWrite(hdl->pal_handle, file->marker, count, (void *) buf, NULL);
676671

677672
if (!ret) {
678673
ret = -PAL_ERRNO;
@@ -771,7 +766,7 @@ static int chroot_write (struct shim_handle * hdl, const void * buf,
771766
lock(hdl->lock);
772767
}
773768

774-
ret = DkStreamWrite(hdl->pal_handle, file->marker, count, buf, NULL) ? :
769+
ret = DkStreamWrite(hdl->pal_handle, file->marker, count, (void *) buf, NULL) ? :
775770
-PAL_ERRNO;
776771

777772
if (ret > 0)
@@ -905,7 +900,7 @@ static int chroot_readdir (struct shim_dentry * dent,
905900

906901
chroot_update_ino(dent);
907902

908-
assert(!memcmp(qstrgetstr(&data->host_uri), "dir:", 4));
903+
assert(strpartcmp_static(qstrgetstr(&data->host_uri), "dir:"));
909904

910905
PAL_HANDLE pal_hdl = DkStreamOpen(qstrgetstr(&data->host_uri),
911906
PAL_ACCESS_RDONLY, 0, 0, 0);

0 commit comments

Comments
 (0)