]> err.no Git - linux-2.6/commitdiff
[Blackfin] arch: fix bug - when we crash, current is not valid
authorRobin Getz <rgetz@blackfin.uclinux.org>
Wed, 26 Mar 2008 01:15:58 +0000 (09:15 +0800)
committerBryan Wu <cooloney@kernel.org>
Wed, 26 Mar 2008 01:15:58 +0000 (09:15 +0800)
Sometimes when we crash, current is not valid, (has been written
over), so the existing code causes a invalid read during exception
context - which is a unrecoverable double fault. This fixes this.

Signed-off-by: Robin Getz <rgetz@blackfin.uclinux.org>
Signed-off-by: Bryan Wu <cooloney@kernel.org>
arch/blackfin/kernel/traps.c

index e8e8f735c2368e5115c4b7393fdfd26fa23b9064..7557d0dce2169d82a6e513b88bfe18418ac492a6 100644 (file)
@@ -655,21 +655,30 @@ void dump_bfin_process(struct pt_regs *fp)
        else if (context & 0x8000)
                printk(KERN_NOTICE "Kernel process context\n");
 
-       if (current->pid && current->mm) {
+       /* Because we are crashing, and pointers could be bad, we check things
+        * pretty closely before we use them
+        */
+       if (!((unsigned long)current & 0x3) && current->pid) {
                printk(KERN_NOTICE "CURRENT PROCESS:\n");
-               printk(KERN_NOTICE "COMM=%s PID=%d\n",
-                       current->comm, current->pid);
-
-               printk(KERN_NOTICE "TEXT = 0x%p-0x%p  DATA = 0x%p-0x%p\n"
-                       KERN_NOTICE "BSS = 0x%p-0x%p   USER-STACK = 0x%p\n"
-                       KERN_NOTICE "\n",
-                       (void *)current->mm->start_code,
-                       (void *)current->mm->end_code,
-                       (void *)current->mm->start_data,
-                       (void *)current->mm->end_data,
-                       (void *)current->mm->end_data,
-                       (void *)current->mm->brk,
-                       (void *)current->mm->start_stack);
+               if (current->comm >= (char *)FIXED_CODE_START)
+                       printk(KERN_NOTICE "COMM=%s PID=%d\n",
+                               current->comm, current->pid);
+               else
+                       printk(KERN_NOTICE "COMM= invalid\n");
+
+               if (!((unsigned long)current->mm & 0x3) && (unsigned long)current->mm >= FIXED_CODE_START)
+                       printk(KERN_NOTICE  "TEXT = 0x%p-0x%p        DATA = 0x%p-0x%p\n"
+                               KERN_NOTICE " BSS = 0x%p-0x%p  USER-STACK = 0x%p\n"
+                               KERN_NOTICE "\n",
+                               (void *)current->mm->start_code,
+                               (void *)current->mm->end_code,
+                               (void *)current->mm->start_data,
+                               (void *)current->mm->end_data,
+                               (void *)current->mm->end_data,
+                               (void *)current->mm->brk,
+                               (void *)current->mm->start_stack);
+               else
+                       printk(KERN_NOTICE "invalid mm\n");
        } else
                printk(KERN_NOTICE "\n" KERN_NOTICE
                     "No Valid process in current context\n");