skas-ex-faultinfo Signed-off-by: Paolo 'Blaisorblade' Giarrusso --- linux-2.6.git-paolo/arch/i386/kernel/ptrace.c | 14 ++++++++++++++ linux-2.6.git-paolo/arch/x86_64/ia32/ptrace32.c | 12 ++++++++++++ linux-2.6.git-paolo/arch/x86_64/kernel/ptrace.c | 20 ++++++++++++++++++++ linux-2.6.git-paolo/include/asm-i386/ptrace.h | 7 +++++++ linux-2.6.git-paolo/include/asm-x86_64/ptrace.h | 13 +++++++++++++ 5 files changed, 66 insertions(+) Index: linux-2.6.git/arch/i386/kernel/ptrace.c =================================================================== --- linux-2.6.git.orig/arch/i386/kernel/ptrace.c +++ linux-2.6.git/arch/i386/kernel/ptrace.c @@ -627,6 +627,20 @@ long arch_ptrace(struct task_struct *chi break; #ifdef CONFIG_PROC_MM + case PTRACE_EX_FAULTINFO: { + struct ptrace_ex_faultinfo fault; + + fault = ((struct ptrace_ex_faultinfo) + { .is_write = child->thread.error_code, + .addr = child->thread.cr2, + .trap_no = child->thread.trap_no }); + ret = copy_to_user((unsigned long *) data, &fault, + sizeof(fault)); + if(ret) + break; + break; + } + case PTRACE_FAULTINFO: { struct ptrace_faultinfo fault; Index: linux-2.6.git/arch/x86_64/kernel/ptrace.c =================================================================== --- linux-2.6.git.orig/arch/x86_64/kernel/ptrace.c +++ linux-2.6.git/arch/x86_64/kernel/ptrace.c @@ -566,6 +566,25 @@ long arch_ptrace(struct task_struct *chi } #ifdef CONFIG_PROC_MM + case PTRACE_EX_FAULTINFO: { + struct ptrace_ex_faultinfo fault; + + /* I checked in thread_struct comments that error_code and cr2 + * are still part of the "fault info" section, so I guess that + * things are unchanged for now. Still to check manuals. BB*/ + fault = ((struct ptrace_ex_faultinfo) + { .is_write = child->thread.error_code, + .addr = child->thread.cr2, + .trap_no = child->thread.trap_no }); + ret = copy_to_user((unsigned long *) data, &fault, + sizeof(fault)); + if(ret) + break; + break; + } + + /*Don't extend this broken interface to x86-64*/ +#if 0 case PTRACE_FAULTINFO: { struct ptrace_faultinfo fault; @@ -581,6 +600,7 @@ long arch_ptrace(struct task_struct *chi break; break; } +#endif case PTRACE_LDT: { struct ptrace_ldt ldt; Index: linux-2.6.git/include/asm-i386/ptrace.h =================================================================== --- linux-2.6.git.orig/include/asm-i386/ptrace.h +++ linux-2.6.git/include/asm-i386/ptrace.h @@ -95,12 +95,19 @@ extern unsigned long profile_pc(struct p /* 53 was used for PTRACE_SIGPENDING, don't reuse it. */ #define PTRACE_LDT 54 #define PTRACE_SWITCH_MM 55 +#define PTRACE_EX_FAULTINFO 56 struct ptrace_faultinfo { int is_write; unsigned long addr; }; +struct ptrace_ex_faultinfo { + int is_write; + unsigned long addr; + int trap_no; +}; + struct ptrace_ldt { int func; void *ptr; Index: linux-2.6.git/include/asm-x86_64/ptrace.h =================================================================== --- linux-2.6.git.orig/include/asm-x86_64/ptrace.h +++ linux-2.6.git/include/asm-x86_64/ptrace.h @@ -82,6 +82,12 @@ struct ptrace_faultinfo32 { compat_ulong_t addr; }; +struct ptrace_ex_faultinfo32 { + compat_int_t is_write; + compat_ulong_t addr; + compat_int_t trap_no; +}; + struct ptrace_ldt32 { compat_int_t func; compat_uptr_t ptr; /*Actually a void pointer on i386, but must be converted.*/ @@ -93,6 +99,12 @@ struct ptrace_faultinfo { unsigned long addr; }; +struct ptrace_ex_faultinfo { + int is_write; + unsigned long addr; + int trap_no; +}; + struct ptrace_ldt { int func; void *ptr; @@ -119,6 +131,7 @@ struct ptrace_ldt { /* 53 was used for PTRACE_SIGPENDING, don't reuse it. */ #define PTRACE_LDT 54 #define PTRACE_SWITCH_MM 55 +#define PTRACE_EX_FAULTINFO 56 /* only useful for access 32bit programs */ #define PTRACE_GET_THREAD_AREA 25 Index: linux-2.6.git/arch/x86_64/ia32/ptrace32.c =================================================================== --- linux-2.6.git.orig/arch/x86_64/ia32/ptrace32.c +++ linux-2.6.git/arch/x86_64/ia32/ptrace32.c @@ -352,6 +352,18 @@ asmlinkage long sys32_ptrace(long reques break; } #ifdef CONFIG_PROC_MM + case PTRACE_EX_FAULTINFO: { + struct ptrace_ex_faultinfo32 fault; + + fault = ((struct ptrace_ex_faultinfo32) + { .is_write = (compat_int_t) child->thread.error_code, + .addr = (compat_uptr_t) child->thread.cr2, + .trap_no = (compat_int_t) child->thread.trap_no }); + ret = copy_to_user((unsigned long *) datap, &fault, + sizeof(fault)); + break; + } + case PTRACE_FAULTINFO: { struct ptrace_faultinfo32 fault;