This Linux kernel change "powerpc/ptrace: Fix setting 512B aligned breakpoints with PTRACE_SET_DEBUGREG" is included in the Linux 3.16.61 release. This change is authored by Michael Neuling <mikey [at] neuling.org> on Thu May 17 15:37:15 2018 +1000. The commit for this change in Linux stable tree is c13e9cc (patch) which is from upstream commit 4f7c06e. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 4f7c06e.
powerpc/ptrace: Fix setting 512B aligned breakpoints with PTRACE_SET_DEBUGREG commit 4f7c06e26ec9cf7fe9f0c54dc90079b6a4f4b2c3 upstream. In commit e2a800beaca1 ("powerpc/hw_brk: Fix off by one error when validating DAWR region end") we fixed setting the DAWR end point to its max value via PPC_PTRACE_SETHWDEBUG. Unfortunately we broke PTRACE_SET_DEBUGREG when setting a 512 byte aligned breakpoint. PTRACE_SET_DEBUGREG currently sets the length of the breakpoint to zero (memset() in hw_breakpoint_init()). This worked with arch_validate_hwbkpt_settings() before the above patch was applied but is now broken if the breakpoint is 512byte aligned. This sets the length of the breakpoint to 8 bytes when using PTRACE_SET_DEBUGREG. Fixes: e2a800beaca1 ("powerpc/hw_brk: Fix off by one error when validating DAWR region end") Signed-off-by: Michael Neuling <firstname.lastname@example.org> Signed-off-by: Michael Ellerman <email@example.com> Signed-off-by: Ben Hutchings <firstname.lastname@example.org>
There is one line of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.
arch/powerpc/kernel/ptrace.c | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c index 1b3f715..36d7ef7 100644 --- a/arch/powerpc/kernel/ptrace.c +++ b/arch/powerpc/kernel/ptrace.c @@ -1011,6 +1011,7 @@ int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, /* Create a new breakpoint request if one doesn't exist already */ hw_breakpoint_init(&attr); attr.bp_addr = hw_brk.address; + attr.bp_len = 8; arch_bp_generic_fields(hw_brk.type, &attr.bp_type);