Skip to content

Commit

Permalink
ARM: 6468/1: backtrace: fix calculation of thread stack base
Browse files Browse the repository at this point in the history
When unwinding stack frames we must take care not to unwind
areas of memory that lie outside of the known extent of the stack.

This patch fixes an incorrect calculation of the stack base where
THREAD_SIZE is added to the stack pointer after it has already
been aligned to this value. Since the ALIGN macro performs this
addition internally, we end up overshooting the base by 8k.

Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Will Deacon authored and Russell King committed Nov 7, 2010
1 parent 261ca20 commit d33aadb
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion arch/arm/kernel/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ int notrace unwind_frame(struct stackframe *frame)

/* only go to a higher address on the stack */
low = frame->sp;
high = ALIGN(low, THREAD_SIZE) + THREAD_SIZE;
high = ALIGN(low, THREAD_SIZE);

/* check current frame pointer is within bounds */
if (fp < (low + 12) || fp + 4 >= high)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/kernel/unwind.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ int unwind_frame(struct stackframe *frame)

/* only go to a higher address on the stack */
low = frame->sp;
high = ALIGN(low, THREAD_SIZE) + THREAD_SIZE;
high = ALIGN(low, THREAD_SIZE);

pr_debug("%s(pc = %08lx lr = %08lx sp = %08lx)\n", __func__,
frame->pc, frame->lr, frame->sp);
Expand Down

0 comments on commit d33aadb

Please sign in to comment.