Index: linux-3.12.33-rt47-i386/kernel/ptrace.c =================================================================== --- linux-3.12.33-rt47-i386.orig/kernel/ptrace.c +++ linux-3.12.33-rt47-i386/kernel/ptrace.c @@ -1068,10 +1068,38 @@ SYSCALL_DEFINE4(ptrace, long, request, l goto out_put_task_struct; } +#define CONFIG_PTRACE_ALLOW_PTRACE_FOR_MY_DEBUGREGS 1 +#if defined(CONFIG_PTRACE_ALLOW_PTRACE_FOR_MY_DEBUGREGS) && defined(X86_32) + { + struct user32 *dummy = NULL; + + if (((pid == current->pid) || + (pid == current->group_leader->pid)) + && ((request == PTRACE_POKEUSR) || + (request == PTRACE_PEEKUSR)) + && (addr >= (long)&dummy->u_debugreg[0]) + && (addr <= (long)&dummy->u_debugreg[7])) + { + printk(KERN_ERR "special mode PTRACE modifying " + "own debug registers!\n"); + + /* + * This is OK!! We allow a process to set its + * own debug registers if PROCWIDE WATCHPOINTS + * are supported. This is a debug feature! + * You know a better solution? + * Fix it, you´re welcome! + */ + } else { +#endif ret = ptrace_check_attach(child, request == PTRACE_KILL || request == PTRACE_INTERRUPT); if (ret < 0) goto out_put_task_struct; +#if defined(CONFIG_PTRACE_ALLOW_PTRACE_FOR_MY_DEBUGREGS) && defined(X86_32) + } + } +#endif ret = arch_ptrace(child, request, addr, data); if (ret || request != PTRACE_DETACH)