1 From 4f7c06e26ec9cf7fe9f0c54dc90079b6a4f4b2c3 Mon Sep 17 00:00:00 2001
2 From: Michael Neuling <mikey@neuling.org>
3 Date: Thu, 17 May 2018 15:37:15 +1000
4 Subject: powerpc/ptrace: Fix setting 512B aligned breakpoints with PTRACE_SET_DEBUGREG
6 From: Michael Neuling <mikey@neuling.org>
8 commit 4f7c06e26ec9cf7fe9f0c54dc90079b6a4f4b2c3 upstream.
10 In commit e2a800beaca1 ("powerpc/hw_brk: Fix off by one error when
11 validating DAWR region end") we fixed setting the DAWR end point to
12 its max value via PPC_PTRACE_SETHWDEBUG. Unfortunately we broke
13 PTRACE_SET_DEBUGREG when setting a 512 byte aligned breakpoint.
15 PTRACE_SET_DEBUGREG currently sets the length of the breakpoint to
16 zero (memset() in hw_breakpoint_init()). This worked with
17 arch_validate_hwbkpt_settings() before the above patch was applied but
18 is now broken if the breakpoint is 512byte aligned.
20 This sets the length of the breakpoint to 8 bytes when using
23 Fixes: e2a800beaca1 ("powerpc/hw_brk: Fix off by one error when validating DAWR region end")
24 Cc: stable@vger.kernel.org # v3.11+
25 Signed-off-by: Michael Neuling <mikey@neuling.org>
26 Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
27 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
30 arch/powerpc/kernel/ptrace.c | 1 +
31 1 file changed, 1 insertion(+)
33 --- a/arch/powerpc/kernel/ptrace.c
34 +++ b/arch/powerpc/kernel/ptrace.c
35 @@ -2362,6 +2362,7 @@ static int ptrace_set_debugreg(struct ta
36 /* Create a new breakpoint request if one doesn't exist already */
37 hw_breakpoint_init(&attr);
38 attr.bp_addr = hw_brk.address;
40 arch_bp_generic_fields(hw_brk.type,