From: Bodo Stroesser Patch 2/3 to implement usage of PTRACE_O_TRACESYSGOOD This is necessary, to fix UMLs bad behavior when a process does a systemcall with syscall-number less than 0. This patch makes SKAS-mode use PTRACE_O_TRACESYSGOOD and fixes the problems in SKAS. Signed-off-by: Bodo Stroesser --- --- a/arch/um/kernel/skas/process.c 2004-10-21 10:50:27.770336304 +0200 +++ b/arch/um/kernel/skas/process.c 2004-10-21 11:34:50.764261057 +0200 @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -54,14 +55,9 @@ /*To use the same value of using_sysemu as the caller, ask it that value (in local_using_sysemu)*/ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu) { - int err, syscall_nr, status; + int err, status; - syscall_nr = PT_SYSCALL_NR(regs->skas.regs); - UPT_SYSCALL_NR(regs) = syscall_nr; - if(syscall_nr < 0){ - relay_signal(SIGTRAP, regs); - return; - } + UPT_SYSCALL_NR(regs) = PT_SYSCALL_NR(regs->skas.regs); if (!local_using_sysemu) { @@ -76,7 +72,7 @@ "errno = %d\n", errno); CATCH_EINTR(err = waitpid(pid, &status, WUNTRACED)); - if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP)) + if((err < 0) || !WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP + 0x80))) panic("handle_trap - failed to wait at end of syscall, " "errno = %d, status = %d\n", errno, status); } @@ -124,6 +120,10 @@ panic("start_userspace : expected SIGSTOP, got status = %d", status); + if (ptrace(PTRACE_SETOPTIONS, pid, NULL, (void *)PTRACE_O_TRACESYSGOOD) < 0) + panic("start_userspace : PTRACE_SETOPTIONS failed, errno=%d\n", + errno); + if(munmap(stack, PAGE_SIZE) < 0) panic("start_userspace : munmap failed, errno = %d\n", errno); @@ -160,9 +160,13 @@ case SIGSEGV: handle_segv(pid); break; - case SIGTRAP: + case SIGTRAP + 0x80: handle_trap(pid, regs, local_using_sysemu); break; + case SIGTRAP: + UPT_SYSCALL_NR(regs) = -1; + relay_signal(SIGTRAP, regs); + break; case SIGIO: case SIGVTALRM: case SIGILL: