do_execveat: kill instead of panic when init_process_stack fails

Change-Id: I0845440260f04ab8e524e118c21d5a137cddb4aa
This commit is contained in:
Masamichi Takagi
2021-03-01 11:27:35 +09:00
parent ae9827f628
commit 86e12fa90c
2 changed files with 30 additions and 14 deletions

View File

@ -3110,11 +3110,15 @@ static int do_execveat(ihk_mc_user_context_t *ctx, int dirfd,
vm->region.map_start = vm->region.map_end = LD_TASK_UNMAPPED_BASE;
/* Create virtual memory ranges and update args/envs */
if (prepare_process_ranges_args_envs(thread, desc, desc,
PTATTR_NO_EXECUTE | PTATTR_WRITABLE | PTATTR_FOR_USER,
argv_flat, argv_flat_len, envp_flat, envp_flat_len) != 0) {
kprintf("execve(): PANIC: preparing ranges, args, envs, stack\n");
panic("");
if ((ret = prepare_process_ranges_args_envs(thread, desc, desc,
PTATTR_NO_EXECUTE | PTATTR_WRITABLE | PTATTR_FOR_USER,
argv_flat, argv_flat_len, envp_flat, envp_flat_len)) != 0) {
kprintf("execve(): ERROR: preparing ranges, args, envs, stack, ret: %d\n",
ret);
preempt_enable();
/* control can't be rolled back because vm_range is gone */
do_kill(thread, thread->proc->pid, thread->tid, SIGKILL, NULL, 0);
goto end;
}
/* Clear host user space PTEs */
@ -3130,6 +3134,8 @@ static int do_execveat(ihk_mc_user_context_t *ctx, int dirfd,
if ((ret = do_syscall(&request, ihk_mc_get_processor_id())) != 0) {
preempt_enable();
/* control can't be rolled back because vm_range is gone */
do_kill(thread, thread->proc->pid, thread->tid, SIGKILL, NULL, 0);
goto end;
}
@ -3148,7 +3154,7 @@ static int do_execveat(ihk_mc_user_context_t *ctx, int dirfd,
thread->sigstack.ss_size = 0;
error = ptrace_report_exec(thread);
if(error) {
if (error) {
kprintf("execve(): ERROR: ptrace_report_exec()\n");
}