From: Bodo Stroesser Patch 1/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. Insert a check for availability and function of ptrace(PTRACE_SETOPTIONS,,,PTRACE_O_TRACESYSGOOD) into the normal ptrace checks at startup. Signed-off-by: Bodo Stroesser --- diff -puNr a/arch/um/include/signal_user.h b/arch/um/include/signal_user.h --- a/arch/um/include/signal_user.h 2004-10-25 13:05:37.008823813 +0200 +++ b/arch/um/include/signal_user.h 2004-10-25 12:18:02.060620621 +0200 @@ -14,6 +14,8 @@ extern void set_handler(int sig, void (* extern int set_signals(int enable); extern int get_signals(void); +#define SYSCALL_TRAP 0x80 + #endif /* diff -puNr a/arch/um/kernel/process.c b/arch/um/kernel/process.c --- a/arch/um/kernel/process.c 2004-10-25 13:05:37.008823813 +0200 +++ b/arch/um/kernel/process.c 2004-10-25 11:41:57.287362002 +0200 @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -255,6 +256,9 @@ void __init check_ptrace(void) printk("Checking that ptrace can change system call numbers..."); pid = start_ptraced_child(&stack); + if(ptrace(PTRACE_SETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) + panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); + while(1){ if(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) panic("check_ptrace : ptrace failed, errno = %d", @@ -262,8 +266,8 @@ void __init check_ptrace(void) CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED)); if(n < 0) panic("check_ptrace : wait failed, errno = %d", errno); - if(!WIFSTOPPED(status) || (WSTOPSIG(status) != SIGTRAP)) - panic("check_ptrace : expected SIGTRAP, " + if(!WIFSTOPPED(status) || (WSTOPSIG(status) != (SIGTRAP|SYSCALL_TRAP))) + panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), " "got status = %d", status); syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET, diff -puNr a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c --- a/arch/um/kernel/ptrace.c 2004-10-25 13:05:37.009823648 +0200 +++ b/arch/um/kernel/ptrace.c 2004-10-25 12:27:41.169919438 +0200 @@ -17,6 +17,7 @@ #include "kern_util.h" #include "ptrace_user.h" #include "skas_ptrace.h" +#include "signal_user.h" /* * Called by kernel/ptrace.c when detaching.. @@ -319,7 +320,7 @@ void syscall_trace(union uml_pt_regs *re /* the 0x80 provides a way for the tracing parent to distinguish between a syscall stop and SIGTRAP delivery */ ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD) - ? 0x80 : 0)); + ? SYSCALL_TRAP : 0)); /* * this isn't the same as continuing with a signal, but it will do