Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

arm64: ptrace: fix compat hardware watchpoint reporting

I'm not sure what I was on when I wrote this, but when iterating over
the hardware watchpoint array (hbp_watch_array), our index is off by
ARM_MAX_BRP, so we walk off the end of our thread_struct...

... except, a dodgy condition in the loop means that it never executes
at all (bp cannot be NULL).

This patch fixes the code so that we remove the bp check and use the
correct index for accessing the watchpoint structures.

Cc: <stable@vger.kernel.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>

+2 -2
-1
arch/arm64/include/asm/hw_breakpoint.h
··· 79 79 */ 80 80 #define ARM_MAX_BRP 16 81 81 #define ARM_MAX_WRP 16 82 - #define ARM_MAX_HBP_SLOTS (ARM_MAX_BRP + ARM_MAX_WRP) 83 82 84 83 /* Virtual debug register bases. */ 85 84 #define AARCH64_DBG_REG_BVR 0
+2 -1
arch/arm64/kernel/ptrace.c
··· 87 87 break; 88 88 } 89 89 } 90 - for (i = ARM_MAX_BRP; i < ARM_MAX_HBP_SLOTS && !bp; ++i) { 90 + 91 + for (i = 0; i < ARM_MAX_WRP; ++i) { 91 92 if (current->thread.debug.hbp_watch[i] == bp) { 92 93 info.si_errno = -((i << 1) + 1); 93 94 break;