ARM: fix /proc/$PID/stack on SMP
authorDeepesh Gujarathi <dgujarathi@nvidia.com>
Wed, 20 Apr 2011 11:47:39 +0000 (17:17 +0530)
committerVarun Colbert <vcolbert@nvidia.com>
Thu, 21 Apr 2011 05:24:07 +0000 (22:24 -0700)
Rabin Vincent reports:
| On SMP, this BUG() in save_stack_trace_tsk() can be easily triggered
| from user space by reading /proc/$PID/stack, where $PID is any pid but
| the current process:
|
| if (tsk != current) {
| #ifdef CONFIG_SMP
| /*
|  * What guarantees do we have here that 'tsk'
|  * is not running on another CPU?
|  */
| BUG();
| #else

Fix this by replacing the BUG() with an entry to terminate the stack
trace, returning an empty trace - I'd rather not expose the dwarf
unwinder to a volatile stack of a running thread.

Change-Id: Ide38bb5eeff09c1d1189bc1a30667a2cc6b96ba2
Reported-by: Rabin Vincent <rabin@rab.in>
Tested-by: Rabin Vincent <rabin@rab.in>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Reviewed-on: http://git-master/r/28325
Reviewed-by: Varun Colbert <vcolbert@nvidia.com>
Tested-by: Varun Colbert <vcolbert@nvidia.com>
arch/arm/kernel/stacktrace.c

index 20b7411e47fdeef9e31606e665957ea862638f5a..f9e16081696155846f9e9e2faa50e5637c38c1b4 100644 (file)
@@ -94,10 +94,13 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
        if (tsk != current) {
 #ifdef CONFIG_SMP
                /*
-                * What guarantees do we have here that 'tsk'
-                * is not running on another CPU?
+                * What guarantees do we have here that 'tsk' is not
+                * running on another CPU?  For now, ignore it as we
+                * can't guarantee we won't explode.
                 */
-               BUG();
+               if (trace->nr_entries < trace->max_entries)
+                       trace->entries[trace->nr_entries++] = ULONG_MAX;
+               return;
 #else
                data.no_sched_functions = 1;
                frame.fp = thread_saved_fp(tsk);