All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kirill Korotaev <dev@sw.ru>
To: linux-kernel@vger.kernel.org, Linus Torvalds <torvalds@osdl.org>,
	Andrew Morton <akpm@osdl.org>
Subject: [PATCH] Fix of stack dump in {SOFT|HARD}IRQs
Date: Fri, 01 Oct 2004 14:51:22 +0400	[thread overview]
Message-ID: <415D36AA.3000907@sw.ru> (raw)

[-- 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
  */

             reply	other threads:[~2004-10-01 10:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-01 10:51 Kirill Korotaev [this message]
2004-10-01 22:08 ` [PATCH] Fix of stack dump in {SOFT|HARD}IRQs Andrew Morton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=415D36AA.3000907@sw.ru \
    --to=dev@sw.ru \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.