瀏覽代碼

[LibOS] shim_do_execve_rtld(): defer disabling preemption

Defer disabling preemption until a point of no-return. Otherwise on
return path the function can return with preemption disabled.
Isaku Yamahata 4 年之前
父節點
當前提交
1e977ecc71
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      LibOS/shim/src/sys/shim_exec.c

+ 2 - 2
LibOS/shim/src/sys/shim_exec.c

@@ -194,8 +194,6 @@ static int shim_do_execve_rtld (struct shim_handle * hdl, const char ** argv,
         return -ENOMEM;
 
     populate_tls(tcb, false);
-    __disable_preempt(&((__libc_tcb_t *) tcb)->shim_tcb); // Temporarily disable preemption
-                                                          // during execve().
     debug("set tcb to %p\n", tcb);
 
     put_handle(cur_thread->exec);
@@ -219,6 +217,8 @@ static int shim_do_execve_rtld (struct shim_handle * hdl, const char ** argv,
     if ((ret = init_stack(argv, envp, &new_argcp, &new_argp, &new_auxp)) < 0)
         return ret;
 
+    __disable_preempt(shim_get_tls()); // Temporarily disable preemption
+                                       // during execve().
     SAVE_PROFILE_INTERVAL(alloc_new_stack_for_exec);
 
     struct execve_rtld_arg arg = {