Browse Source

[Pal/{Linux, Linux-SGX, FreeBSD}] Remove close() right before dup2()

As dup2() system call closes target file descriptor, close() right
before dup2() doesn't make sense. Or worse, it opens a window for race
condition.
So remove close() right before dup2().

Signed-off-by: Isaku Yamahata <isaku.yamahata@gmail.com>
Isaku Yamahata 5 years ago
parent
commit
ef8de1d48f

+ 0 - 1
Pal/src/host/FreeBSD/db_process.c

@@ -137,7 +137,6 @@ static int child_process (void * param)
     struct proc_param * proc_param = param;
     int ret;
 
-    INLINE_SYSCALL(close, 1, PROC_INIT_FD);
     ret = INLINE_SYSCALL(dup2, 2, proc_param->parent->process.stream_in,
                          PROC_INIT_FD);
     if (IS_ERR(ret))

+ 0 - 1
Pal/src/host/Linux-SGX/sgx_process.c

@@ -87,7 +87,6 @@ int sgx_create_process (const char * uri, int nargs, const char ** args,
         for (int i = 0 ; i < 3 ; i++)
             INLINE_SYSCALL(close, 1, proc_fds[1][i]);
 
-        INLINE_SYSCALL(close, 1, PROC_INIT_FD);
         rete = INLINE_SYSCALL(dup2, 2, proc_fds[0][0], PROC_INIT_FD);
         if (IS_ERR(rete))
             goto out_child;

+ 0 - 1
Pal/src/host/Linux/db_process.c

@@ -142,7 +142,6 @@ static int child_process (void * param)
     struct proc_param * proc_param = param;
     int ret;
 
-    INLINE_SYSCALL(close, 1, PROC_INIT_FD);
     ret = INLINE_SYSCALL(dup2, 2, proc_param->parent->process.stream_in,
                          PROC_INIT_FD);
     if (IS_ERR(ret))