sparc64: Fix end-of-stack checking in save_stack_trace().

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>

+4 -2
+4 -2
arch/sparc64/kernel/stacktrace.c
··· 26 26 27 27 /* Bogus frame pointer? */ 28 28 if (fp < (thread_base + sizeof(struct thread_info)) || 29 - fp >= (thread_base + THREAD_SIZE)) 29 + fp > (thread_base + THREAD_SIZE - sizeof(struct sparc_stackf))) 30 30 break; 31 31 32 32 sf = (struct sparc_stackf *) fp; 33 33 regs = (struct pt_regs *) (sf + 1); 34 34 35 - if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) { 35 + if (((unsigned long)regs <= 36 + (thread_base + THREAD_SIZE - sizeof(*regs))) && 37 + (regs->magic & ~0x1ff) == PT_REGS_MAGIC) { 36 38 if (!(regs->tstate & TSTATE_PRIV)) 37 39 break; 38 40 pc = regs->tpc;