public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix of stack dump in {SOFT|HARD}IRQs
@ 2004-10-01 10:51 Kirill Korotaev
  2004-10-01 22:08 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Kirill Korotaev @ 2004-10-01 10:51 UTC (permalink / raw)
  To: linux-kernel, Linus Torvalds, Andrew Morton

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

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>

Kirill

[-- Attachment #2: diff-dumpstack --]
[-- Type: text/plain, Size: 1472 bytes --]

--- ./arch/i386/kernel/traps.c.dumpstack	2004-10-01 14:21:40.000000000 +0400
+++ ./arch/i386/kernel/traps.c	2004-10-01 14:30:10.109733400 +0400
@@ -95,11 +95,16 @@ static int kstack_depth_to_print = 24;
 
 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
--- ./arch/i386/kernel/irq.c.dumpstack	2004-09-20 14:14:58.000000000 +0400
+++ ./arch/i386/kernel/irq.c	2004-10-01 14:28:15.806110192 +0400
@@ -1126,6 +1126,21 @@ void init_irq_proc (void)
 static char softirq_stack[NR_CPUS * THREAD_SIZE]  __attribute__((__aligned__(THREAD_SIZE)));
 static char hardirq_stack[NR_CPUS * THREAD_SIZE]  __attribute__((__aligned__(THREAD_SIZE)));
 
+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;
+}
+
 /*
  * allocate per-cpu stacks for hardirq and for softirq processing
  */

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Fix of stack dump in {SOFT|HARD}IRQs
  2004-10-01 10:51 [PATCH] Fix of stack dump in {SOFT|HARD}IRQs Kirill Korotaev
@ 2004-10-01 22:08 ` Andrew Morton
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2004-10-01 22:08 UTC (permalink / raw)
  To: Kirill Korotaev; +Cc: linux-kernel, torvalds

Kirill Korotaev <dev@sw.ru> wrote:
>
> 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.

Thanks for fixing that up.

In future, please ensure that patches are in `patch -p1' form, as described
in http://www.zip.com.au/~akpm/linux/patches/stuff/tpp.txt.

And please don't declare external functions in .c files - it defeats
compiler typechecking.  I'll use the below fixup for that.

--- 25/arch/i386/kernel/irq.c~fix-of-stack-dump-in-soft-hardirqs-cleanup	Fri Oct  1 15:05:24 2004
+++ 25-akpm/arch/i386/kernel/irq.c	Fri Oct  1 15:05:45 2004
@@ -10,12 +10,14 @@
  * io_apic.c.)
  */
 
-#include <asm/uaccess.h>
 #include <linux/module.h>
 #include <linux/seq_file.h>
 #include <linux/interrupt.h>
 #include <linux/kernel_stat.h>
 
+#include <asm/uaccess.h>
+#include <asm/hardirq.h>
+
 #ifdef CONFIG_4KSTACKS
 /*
  * per-CPU IRQ handling contexts (thread information and stack)
diff -puN arch/i386/kernel/traps.c~fix-of-stack-dump-in-soft-hardirqs-cleanup arch/i386/kernel/traps.c
--- 25/arch/i386/kernel/traps.c~fix-of-stack-dump-in-soft-hardirqs-cleanup	Fri Oct  1 15:05:24 2004
+++ 25-akpm/arch/i386/kernel/traps.c	Fri Oct  1 15:06:01 2004
@@ -50,6 +50,7 @@
 #include <asm/smp.h>
 #include <asm/arch_hooks.h>
 #include <asm/kdebug.h>
+#include <asm/hardirq.h>
 
 #include <linux/irq.h>
 #include <linux/module.h>
@@ -107,8 +108,6 @@ int register_die_notifier(struct notifie
 
 static int valid_stack_ptr(struct task_struct *task, void *p)
 {
-	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 &&
diff -puN include/asm-i386/hardirq.h~fix-of-stack-dump-in-soft-hardirqs-cleanup include/asm-i386/hardirq.h
--- 25/include/asm-i386/hardirq.h~fix-of-stack-dump-in-soft-hardirqs-cleanup	Fri Oct  1 15:05:24 2004
+++ 25-akpm/include/asm-i386/hardirq.h	Fri Oct  1 15:06:29 2004
@@ -36,4 +36,7 @@ static inline void ack_bad_irq(unsigned 
 #endif
 }
 
+struct task_struct;
+int is_irq_stack_ptr(struct task_struct *task, void *p);
+
 #endif /* __ASM_HARDIRQ_H */
_


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-10-01 22:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-01 10:51 [PATCH] Fix of stack dump in {SOFT|HARD}IRQs Kirill Korotaev
2004-10-01 22:08 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox