Commit b87a95ad authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds

ptrace/x86: ptrace_write_dr7() should create bp if !disabled

Commit 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: default avatarOleg Nesterov <oleg@redhat.com>
Reported-by: default avatarJan Kratochvil <jan.kratochvil@redhat.com>
Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Michael Neuling <mikey@neuling.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Prasad <prasad@linux.vnet.ibm.com>
Cc: Russell King <linux@arm.linux.org.uk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9afe33ad
...@@ -670,15 +670,18 @@ static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data) ...@@ -670,15 +670,18 @@ static int ptrace_write_dr7(struct task_struct *tsk, unsigned long data)
if (!bp) { if (!bp) {
if (disabled) if (disabled)
continue; continue;
/*
* We should have at least an inactive breakpoint at bp = ptrace_register_breakpoint(tsk,
* this slot. It means the user is writing dr7 without len, type, 0, disabled);
* having written the address register first. if (IS_ERR(bp)) {
*/ rc = PTR_ERR(bp);
rc = -EINVAL;
break; break;
} }
thread->ptrace_bps[i] = bp;
continue;
}
rc = ptrace_modify_breakpoint(bp, len, type, disabled); rc = ptrace_modify_breakpoint(bp, len, type, disabled);
if (rc) if (rc)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment