Преглед на файлове

[Pal/Linux-SGX] Set ready_for_exceptions earlier during enclave initialization

Previously, there was a segfault if a child enclave issued a cpuid instruction
during init_child_process(), because the enclave was not yet set up to handle
exceptions. This commit moves this set up earlier in initialization sequence.
Thomas Knauth преди 5 години
родител
ревизия
9e0f50ee92
променени са 1 файла, в които са добавени 6 реда и са изтрити 6 реда
  1. 6 6
      Pal/src/host/Linux-SGX/db_main.c

+ 6 - 6
Pal/src/host/Linux-SGX/db_main.c

@@ -337,6 +337,12 @@ void pal_linux_main(char * uptr_args, uint64_t args_size,
 
     pal_state.start_time = start_time;
 
+    linux_state.uid = pal_sec.uid;
+    linux_state.gid = pal_sec.gid;
+    linux_state.process_id = (start_time & (~0xffff)) | pal_sec.pid;
+
+    SET_ENCLAVE_TLS(ready_for_exceptions, 1UL);
+
     /* if there is a parent, create parent handle */
     if (pal_sec.ppid) {
         if ((rv = init_child_process(&parent)) < 0) {
@@ -345,15 +351,9 @@ void pal_linux_main(char * uptr_args, uint64_t args_size,
         }
     }
 
-    linux_state.uid = pal_sec.uid;
-    linux_state.gid = pal_sec.gid;
-    linux_state.process_id = (start_time & (~0xffff)) | pal_sec.pid;
-
     /* now let's mark our enclave as initialized */
     pal_enclave_state.enclave_flags |= PAL_ENCLAVE_INITIALIZED;
 
-    SET_ENCLAVE_TLS(ready_for_exceptions, 1UL);
-
     /*
      * We create dummy handles for exec and manifest here to make the logic in
      * pal_main happy and pass the path of them. The handles can't be used to