Commit 70b19320 authored by Andrew Morton's avatar Andrew Morton Committed by David S. Miller

[PATCH] show_task() is not SMP safe

From: Arnd Bergmann <arnd@arndb.de>

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.
parent 87f095b8
...@@ -2580,13 +2580,13 @@ static void show_task(task_t * p) ...@@ -2580,13 +2580,13 @@ static void show_task(task_t * p)
else else
printk("?"); printk("?");
#if (BITS_PER_LONG == 32) #if (BITS_PER_LONG == 32)
if (p == current) if (state == TASK_RUNNING)
printk(" current "); printk(" running ");
else else
printk(" %08lX ", thread_saved_pc(p)); printk(" %08lX ", thread_saved_pc(p));
#else #else
if (p == current) if (state == TASK_RUNNING)
printk(" current task "); printk(" running task ");
else else
printk(" %016lx ", thread_saved_pc(p)); printk(" %016lx ", thread_saved_pc(p));
#endif #endif
...@@ -2608,6 +2608,7 @@ static void show_task(task_t * p) ...@@ -2608,6 +2608,7 @@ static void show_task(task_t * p)
else else
printk(" (NOTLB)\n"); printk(" (NOTLB)\n");
if (state != TASK_RUNNING)
show_stack(p, NULL); show_stack(p, NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment