arm64: ptrace: fix compat hardware watchpoint reporting
authorWill Deacon <will.deacon@arm.com>
Fri, 22 Aug 2014 13:13:24 +0000 (14:13 +0100)
committerMark Brown <broonie@kernel.org>
Thu, 22 Jan 2015 21:27:28 +0000 (21:27 +0000)
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>
(cherry picked from commit 27d7ff273c2aad37b28f6ff0cab2cfa35b51e648)
Signed-off-by: Mark Brown <broonie@kernel.org>
arch/arm64/include/asm/hw_breakpoint.h
arch/arm64/kernel/ptrace.c

index d064047612b12acb2668927c4b3cedf504d22c11..52b484b6aa1a7fec251a72b028f655523c74236a 100644 (file)
@@ -79,7 +79,6 @@ static inline void decode_ctrl_reg(u32 reg,
  */
 #define ARM_MAX_BRP            16
 #define ARM_MAX_WRP            16
-#define ARM_MAX_HBP_SLOTS      (ARM_MAX_BRP + ARM_MAX_WRP)
 
 /* Virtual debug register bases. */
 #define AARCH64_DBG_REG_BVR    0
index 71c6a623e226e594a499954653bd91ee307bd50a..f9177993d1353d389dfa7d911b61420ab285252e 100644 (file)
@@ -81,7 +81,8 @@ static void ptrace_hbptriggered(struct perf_event *bp,
                        break;
                }
        }
-       for (i = ARM_MAX_BRP; i < ARM_MAX_HBP_SLOTS && !bp; ++i) {
+
+       for (i = 0; i < ARM_MAX_WRP; ++i) {
                if (current->thread.debug.hbp_watch[i] == bp) {
                        info.si_errno = -((i << 1) + 1);
                        break;