From: Oleg Nesterov Date: Thu, 27 Jun 2013 23:53:48 +0000 (+1000) Subject: ptrace/x86: ptrace_write_dr7() should create bp if !disabled X-Git-Tag: next-20130628~3^2~121 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=cd217e369476f1576e8eef8e7db65e0dd53f16a0;p=karo-tx-linux.git ptrace/x86: ptrace_write_dr7() should create bp if !disabled 24f1e32c ("hw-breakpoints: Rewrite the hw-breakpoints layer on top of perf events") introduced the minor regression. Before this commit PTRACE_POKEUSER DR7, enableDR0 PTRACE_POKEUSER DR0, address was perfectly valid, now PTRACE_POKEUSER(DR7) fails if DR0 was not previously initialized by PTRACE_POKEUSER(DR0). Change ptrace_write_dr7() to do ptrace_register_breakpoint(addr => 0) if !bp && !disabled. This fixes watchpoint-zeroaddr from ptrace-tests, see https://bugzilla.redhat.com/show_bug.cgi?id=660204. Signed-off-by: Oleg Nesterov Reported-by: Jan Kratochvil Acked-by: Frederic Weisbecker Cc: Benjamin Herrenschmidt Cc: Ingo Molnar Cc: Michael Neuling Cc: Paul Mackerras Cc: Paul Mundt Cc: Will Deacon Cc: Prasad Cc: Russell King Signed-off-by: Andrew Morton --- diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 052636801b41..5c387b3dce3f 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -670,13 +670,16 @@ restore: if (!bp) { if (disabled) continue; - /* - * We should have at least an inactive breakpoint at - * this slot. It means the user is writing dr7 without - * having written the address register first. - */ - rc = -EINVAL; - break; + + bp = ptrace_register_breakpoint(tsk, + len, type, 0, disabled); + if (IS_ERR(bp)) { + rc = PTR_ERR(bp); + break; + } + + thread->ptrace_bps[i] = bp; + continue; } rc = ptrace_modify_breakpoint(bp, len, type, disabled);