Skip to content

Commit

Permalink
sparc64: Fix end-of-stack checking in save_stack_trace().
Browse files Browse the repository at this point in the history
Bug reported by Alexander Beregalov.

Before we dereference the stack frame or try to peek at the
pt_regs magic value, make sure the entire object is within
the kernel stack bounds.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 8, 2008
1 parent 764f257 commit 433c5f7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arch/sparc64/kernel/stacktrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ void save_stack_trace(struct stack_trace *trace)

/* Bogus frame pointer? */
if (fp < (thread_base + sizeof(struct thread_info)) ||
fp >= (thread_base + THREAD_SIZE))
fp > (thread_base + THREAD_SIZE - sizeof(struct sparc_stackf)))
break;

sf = (struct sparc_stackf *) fp;
regs = (struct pt_regs *) (sf + 1);

if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
if (((unsigned long)regs <=
(thread_base + THREAD_SIZE - sizeof(*regs))) &&
(regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
if (!(regs->tstate & TSTATE_PRIV))
break;
pc = regs->tpc;
Expand Down

0 comments on commit 433c5f7

Please sign in to comment.