From: Kirill Korotaev <dev@sw.ru>

This patch fixes incorrect check for stack ptr in
show_trace()->valid_stack_ptr().  When called from hardirq/softirq
show_trace() prints "Stack pointer is garbage, not printing trace" message
instead of call traces.

Signed-Off-By: Kirill Korotaev <dev@sw.ru>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/arch/i386/kernel/irq.c   |   15 +++++++++++++++
 25-akpm/arch/i386/kernel/traps.c |   15 ++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff -puN arch/i386/kernel/irq.c~fix-of-stack-dump-in-soft-hardirqs arch/i386/kernel/irq.c
--- 25/arch/i386/kernel/irq.c~fix-of-stack-dump-in-soft-hardirqs	2004-10-03 10:03:12.491987064 -0700
+++ 25-akpm/arch/i386/kernel/irq.c	2004-10-03 10:03:12.496986304 -0700
@@ -195,6 +195,21 @@ EXPORT_SYMBOL(do_softirq);
 
 atomic_t irq_err_count;
 
+int is_irq_stack_ptr(struct task_struct *task, void *p)
+{
+	unsigned long off;
+
+	off = task->thread_info->cpu * THREAD_SIZE;
+	if (p >= (void *)hardirq_stack + off &&
+	    p < (void *)hardirq_stack + off + THREAD_SIZE)
+		return 1;
+	if (p >= (void *)softirq_stack + off &&
+	    p < (void *)softirq_stack + off + THREAD_SIZE)
+		return 1;
+
+	return 0;
+}
+
 /*
  * /proc/interrupts printing:
  */
diff -puN arch/i386/kernel/traps.c~fix-of-stack-dump-in-soft-hardirqs arch/i386/kernel/traps.c
--- 25/arch/i386/kernel/traps.c~fix-of-stack-dump-in-soft-hardirqs	2004-10-03 10:03:12.492986912 -0700
+++ 25-akpm/arch/i386/kernel/traps.c	2004-10-03 10:03:12.497986152 -0700
@@ -107,11 +107,16 @@ int register_die_notifier(struct notifie
 
 static int valid_stack_ptr(struct task_struct *task, void *p)
 {
-	if (p <= (void *)task->thread_info)
-		return 0;
-	if (kstack_end(p))
-		return 0;
-	return 1;
+	extern int is_irq_stack_ptr(struct task_struct *, void *);
+
+	if (is_irq_stack_ptr(task, p))
+		return 1;
+	if (p >= (void *)task->thread_info &&
+	    p < (void *)task->thread_info + THREAD_SIZE &&
+	    !kstack_end(p))
+		return 1;
+
+	return 0;
 }
 
 #ifdef CONFIG_FRAME_POINTER
_