Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: David Miller
Date: Thursday, August 7, 2008 - 11:01 pm

From: "Alexander Beregalov" <a.beregalov@gmail.com>
Date: Mon, 7 Jul 2008 19:59:04 +0400


I have finally reproduced the problem locally and figured out the
bug.

Please try this patch:

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>

diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c
index c73ce3f..c5576e8 100644
--- a/arch/sparc64/kernel/stacktrace.c
+++ b/arch/sparc64/kernel/stacktrace.c
@@ -25,13 +25,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;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Fri Jun 20, 3:51 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Jun 20, 4:12 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Fri Jun 20, 4:21 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Jun 20, 4:36 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Mon Jul 7, 2:19 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Mon Jul 7, 4:01 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Mikael Pettersson, (Mon Jul 7, 6:05 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Mon Jul 7, 8:59 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Thu Aug 7, 11:01 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Aug 8, 2:31 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Fri Aug 8, 2:40 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Aug 8, 3:14 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Fri Aug 8, 3:38 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Aug 8, 3:56 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Fri Aug 8, 4:18 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Aug 8, 4:52 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Fri Aug 8, 7:28 am)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Fri Aug 8, 4:17 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, David Miller, (Wed Aug 13, 8:53 pm)
Re: 2.6.26-rc: SPARC: Sun Ultra 10 can not boot, Alexander Beregalov, (Thu Aug 14, 3:19 am)