[1/2] powerpc/ptrace: Fix enforcement of DAWR contraints

Message ID 20180517053715.24011-1-mikey@neuling.org
State Accepted
Commit cd6ef7eebf171bfcba7dc2df719c2a4958775040
Headers show
Series
  • [1/2] powerpc/ptrace: Fix enforcement of DAWR contraints
Related show

Commit Message

Michael Neuling May 17, 2018, 5:37 a.m.
Back when we first introduced the DAWR in this commit:
  4ae7ebe952 powerpc: Change hardware breakpoint to allow longer ranges

We screwed up the constraint making it a 1024 byte boundary rather
than a 512. This makes the check overly permissive. Fortunately GDB is
the only real user and it always did they right thing, so we never
noticed.

This fixes the constraint to 512 bytes.

Signed-off-by: Michael Neuling <mikey@neuling.org>
cc: <stable@vger.kernel.org> # v3.9+
---
 arch/powerpc/kernel/hw_breakpoint.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Michael Ellerman May 21, 2018, 10:01 a.m. | #1
On Thu, 2018-05-17 at 05:37:14 UTC, Michael Neuling wrote:
> Back when we first introduced the DAWR in this commit:
>   4ae7ebe952 powerpc: Change hardware breakpoint to allow longer ranges
> 
> We screwed up the constraint making it a 1024 byte boundary rather
> than a 512. This makes the check overly permissive. Fortunately GDB is
> the only real user and it always did they right thing, so we never
> noticed.
> 
> This fixes the constraint to 512 bytes.
> 
> Signed-off-by: Michael Neuling <mikey@neuling.org>
> cc: <stable@vger.kernel.org> # v3.9+

Series applied to powerpc next, thanks.

https://git.kernel.org/powerpc/c/cd6ef7eebf171bfcba7dc2df719c2a

cheers

Patch

diff --git a/arch/powerpc/kernel/hw_breakpoint.c b/arch/powerpc/kernel/hw_breakpoint.c
index 4c1012b80d..80547dad37 100644
--- a/arch/powerpc/kernel/hw_breakpoint.c
+++ b/arch/powerpc/kernel/hw_breakpoint.c
@@ -178,8 +178,8 @@  int arch_validate_hwbkpt_settings(struct perf_event *bp)
 	if (cpu_has_feature(CPU_FTR_DAWR)) {
 		length_max = 512 ; /* 64 doublewords */
 		/* DAWR region can't cross 512 boundary */
-		if ((bp->attr.bp_addr >> 10) != 
-		    ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 10))
+		if ((bp->attr.bp_addr >> 9) !=
+		    ((bp->attr.bp_addr + bp->attr.bp_len - 1) >> 9))
 			return -EINVAL;
 	}
 	if (info->len >