From ec202a1ca9b31872f7fade1164a2fe892cfd6d6a Mon Sep 17 00:00:00 2001 From: Dominique Martinet Date: Mon, 18 Jun 2018 14:38:26 +0900 Subject: [PATCH] execve: fix execve with oversubscribing Issue: #1072 Change-Id: I88446e075b60de3c94cad2a19a4731e58037ea63 --- kernel/syscall.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/kernel/syscall.c b/kernel/syscall.c index 7242f6a0..4f01f781 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -2245,6 +2245,8 @@ SYSCALL_DECLARE(execve) /* Unmap all memory areas of the process, userspace will be gone */ munmap_all(); + /* Code assumes no process switch from here on */ + preempt_disable(); ihk_mc_init_user_process(&thread->ctx, &thread->uctx, ((char *)thread) + KERNEL_STACK_NR_PAGES * PAGE_SIZE, desc->entry, 0); @@ -2308,12 +2310,16 @@ end: /* Lock run queue because enter_user_mode expects to release it */ cpu_local_var(runq_irqstate) = ihk_mc_spinlock_lock(&(get_this_cpu_local_var()->runq_lock)); + preempt_enable(); ihk_mc_switch_context(NULL, &thread->ctx, thread); /* not reached */ return -EFAULT; } + + /* no preempt_enable, errors can only happen before we disabled it */ + return ret; }