From: Arnd Bergmann <arnd@arndb.de>
To: linux-kernel@vger.kernel.org
Cc: Christian Borntraeger <cborntra@de.ibm.com>
Subject: show_task() is not SMP safe
Date: Tue, 27 Jan 2004 13:06:37 +0100 [thread overview]
Message-ID: <200401271306.37209.arnd@arndb.de> (raw)
Christian Bornträger noticed that the kernel can crash after
<SysRq>-T. It appears that the show_task function gets called
for all tasks, which does not work if one of the tasks is
running in a system call on another CPU. In that case the
result of thread_saved_pc and show_stack is undefined and
likely to cause a crash.
For tasks running in user space on other CPUs, show_task()
is probably harmless, but I'm not sure if that's true on all
architectures.
The patch below is still racy for tasks that are about to
sleep, but it demonstrates the problem.
In the same function, there is another (harmless) bug that causes
the "free stack" indicator to be wrong. It can take any value
between zero and the intended meaning unless __alloc_thread_info
is modified to clear newly allocated stack memory.
Arnd <><
Index: kernel/sched.c
===================================================================
RCS file: /home/cvs/linux-2.5/kernel/sched.c,v
retrieving revision 1.56
diff -u -r1.56 sched.c
--- kernel/sched.c 24 Nov 2003 09:44:34 -0000 1.56
+++ kernel/sched.c 27 Jan 2004 11:50:55 -0000
@@ -2457,13 +2457,13 @@
else
printk(" ");
#if (BITS_PER_LONG == 32)
- if (p == current)
- printk(" current ");
+ if (state == TASK_RUNNING)
+ printk(" running ");
else
printk(" %08lX ", thread_saved_pc(p));
#else
- if (p == current)
- printk(" current task ");
+ if (state == TASK_RUNNING)
+ printk(" running task ");
else
printk(" %016lx ", thread_saved_pc(p));
#endif
@@ -2491,7 +2491,8 @@
else
printk(" (NOTLB)\n");
- show_stack(p, NULL);
+ if (state != TASK_RUNNING)
+ show_stack(p, NULL);
}
void show_state(void)
reply other threads:[~2004-01-27 12:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200401271306.37209.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=cborntra@de.ibm.com \
--cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox