]> err.no Git - linux-2.6/commitdiff
sparc64: Fix end-of-stack checking in save_stack_trace().
authorDavid S. Miller <davem@davemloft.net>
Fri, 8 Aug 2008 06:04:37 +0000 (23:04 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Aug 2008 06:04:37 +0000 (23:04 -0700)
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>
arch/sparc64/kernel/stacktrace.c

index b3e3737750d8bfb49701a862a6c57a821303fc18..e9d7f0660f2e044643182cb2e85f9fde7dc5006b 100644 (file)
@@ -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;