Skip to content

Commit

Permalink
arm64: ptrace: fix compat hardware watchpoint reporting
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Will Deacon committed Aug 28, 2014
1 parent 5843be2 commit 27d7ff2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
1 change: 0 additions & 1 deletion arch/arm64/include/asm/hw_breakpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion arch/arm64/kernel/ptrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,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;
Expand Down

0 comments on commit 27d7ff2

Please sign in to comment.