Commit bcdcd8e725b923ad7c0de809680d5d5658a7bf8c

Authored by Pavel Emelianov
Committed by Linus Torvalds
1 parent 74489a91dd

Report that kernel is tainted if there was an OOPS

If the kernel OOPSed or BUGed then it probably should be considered as
tainted.  Thus, all subsequent OOPSes and SysRq dumps will report the
tainted kernel.  This saves a lot of time explaining oddities in the
calltraces.

Signed-off-by: Pavel Emelianov <xemul@openvz.org>
Acked-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: <linux-arch@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[ Added parisc patch from Matthew Wilson  -Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 21 changed files with 24 additions and 2 deletions Side-by-side Diff

Documentation/oops-tracing.txt
... ... @@ -251,6 +251,8 @@
251 251 7: 'U' if a user or user application specifically requested that the
252 252 Tainted flag be set, ' ' otherwise.
253 253  
  254 + 8: 'D' if the kernel has died recently, i.e. there was an OOPS or BUG.
  255 +
254 256 The primary reason for the 'Tainted: ' string is to tell kernel
255 257 debuggers if this is a clean kernel or if anything unusual has
256 258 occurred. Tainting is permanent: even if an offending module is
arch/alpha/kernel/traps.c
... ... @@ -184,6 +184,7 @@
184 184 #endif
185 185 printk("%s(%d): %s %ld\n", current->comm, current->pid, str, err);
186 186 dik_show_regs(regs, r9_15);
  187 + add_taint(TAINT_DIE);
187 188 dik_show_trace((unsigned long *)(regs+1));
188 189 dik_show_code((unsigned int *)regs->pc);
189 190  
arch/arm/kernel/traps.c
... ... @@ -249,6 +249,7 @@
249 249 bust_spinlocks(1);
250 250 __die(str, err, thread, regs);
251 251 bust_spinlocks(0);
  252 + add_taint(TAINT_DIE);
252 253 spin_unlock_irq(&die_lock);
253 254  
254 255 if (in_interrupt())
arch/arm26/kernel/traps.c
... ... @@ -185,6 +185,7 @@
185 185 printk("Internal error: %s: %x\n", str, err);
186 186 printk("CPU: %d\n", smp_processor_id());
187 187 show_regs(regs);
  188 + add_taint(TAINT_DIE);
188 189 printk("Process %s (pid: %d, stack limit = 0x%p)\n",
189 190 current->comm, current->pid, end_of_stack(tsk));
190 191  
arch/avr32/kernel/traps.c
... ... @@ -56,6 +56,7 @@
56 56 show_regs_log_lvl(regs, KERN_EMERG);
57 57 show_stack_log_lvl(current, regs->sp, regs, KERN_EMERG);
58 58 bust_spinlocks(0);
  59 + add_taint(TAINT_DIE);
59 60 spin_unlock_irq(&die_lock);
60 61  
61 62 if (in_interrupt())
arch/i386/kernel/traps.c
... ... @@ -433,6 +433,7 @@
433 433  
434 434 bust_spinlocks(0);
435 435 die.lock_owner = -1;
  436 + add_taint(TAINT_DIE);
436 437 spin_unlock_irqrestore(&die.lock, flags);
437 438  
438 439 if (!regs)
arch/ia64/kernel/traps.c
... ... @@ -69,6 +69,7 @@
69 69  
70 70 bust_spinlocks(0);
71 71 die.lock_owner = -1;
  72 + add_taint(TAINT_DIE);
72 73 spin_unlock_irq(&die.lock);
73 74  
74 75 if (panic_on_oops)
arch/m68k/kernel/traps.c
... ... @@ -1170,6 +1170,7 @@
1170 1170 console_verbose();
1171 1171 printk("%s: %08x\n",str,nr);
1172 1172 show_registers(fp);
  1173 + add_taint(TAINT_DIE);
1173 1174 do_exit(SIGSEGV);
1174 1175 }
1175 1176  
arch/m68knommu/kernel/traps.c
... ... @@ -83,6 +83,7 @@
83 83 printk(KERN_EMERG "Process %s (pid: %d, stackpage=%08lx)\n",
84 84 current->comm, current->pid, PAGE_SIZE+(unsigned long)current);
85 85 show_stack(NULL, (unsigned long *)fp);
  86 + add_taint(TAINT_DIE);
86 87 do_exit(SIGSEGV);
87 88 }
88 89  
arch/mips/kernel/traps.c
... ... @@ -326,6 +326,7 @@
326 326 #endif /* CONFIG_MIPS_MT_SMTC */
327 327 printk("%s[#%d]:\n", str, ++die_counter);
328 328 show_registers(regs);
  329 + add_taint(TAINT_DIE);
329 330 spin_unlock_irq(&die_lock);
330 331  
331 332 if (in_interrupt())
arch/parisc/kernel/traps.c
... ... @@ -264,6 +264,7 @@
264 264  
265 265 show_regs(regs);
266 266 dump_stack();
  267 + add_taint(TAINT_DIE);
267 268  
268 269 if (in_interrupt())
269 270 panic("Fatal exception in interrupt");
arch/powerpc/kernel/traps.c
... ... @@ -149,6 +149,7 @@
149 149  
150 150 bust_spinlocks(0);
151 151 die.lock_owner = -1;
  152 + add_taint(TAINT_DIE);
152 153 spin_unlock_irqrestore(&die.lock, flags);
153 154  
154 155 if (kexec_should_crash(current) ||
arch/ppc/kernel/traps.c
... ... @@ -92,6 +92,7 @@
92 92 if (nl)
93 93 printk("\n");
94 94 show_regs(fp);
  95 + add_taint(TAINT_DIE);
95 96 spin_unlock_irq(&die_lock);
96 97 /* do_exit() should take care of panic'ing from an interrupt
97 98 * context so we don't handle it here
arch/s390/kernel/traps.c
... ... @@ -262,6 +262,7 @@
262 262 print_modules();
263 263 show_regs(regs);
264 264 bust_spinlocks(0);
  265 + add_taint(TAINT_DIE);
265 266 spin_unlock_irq(&die_lock);
266 267 if (in_interrupt())
267 268 panic("Fatal exception in interrupt");
arch/sh/kernel/traps.c
... ... @@ -103,6 +103,7 @@
103 103 (unsigned long)task_stack_page(current));
104 104  
105 105 bust_spinlocks(0);
  106 + add_taint(TAINT_DIE);
106 107 spin_unlock_irq(&die_lock);
107 108  
108 109 if (kexec_should_crash(current))
arch/sparc/kernel/traps.c
... ... @@ -101,6 +101,7 @@
101 101  
102 102 printk("%s(%d): %s [#%d]\n", current->comm, current->pid, str, ++die_counter);
103 103 show_regs(regs);
  104 + add_taint(TAINT_DIE);
104 105  
105 106 __SAVE; __SAVE; __SAVE; __SAVE;
106 107 __SAVE; __SAVE; __SAVE; __SAVE;
arch/sparc64/kernel/traps.c
... ... @@ -2225,6 +2225,7 @@
2225 2225 notify_die(DIE_OOPS, str, regs, 0, 255, SIGSEGV);
2226 2226 __asm__ __volatile__("flushw");
2227 2227 __show_regs(regs);
  2228 + add_taint(TAINT_DIE);
2228 2229 if (regs->tstate & TSTATE_PRIV) {
2229 2230 struct reg_window *rw = (struct reg_window *)
2230 2231 (regs->u_regs[UREG_FP] + STACK_BIAS);
arch/x86_64/kernel/traps.c
... ... @@ -518,6 +518,7 @@
518 518 printk("\n");
519 519 notify_die(DIE_OOPS, str, regs, err, current->thread.trap_no, SIGSEGV);
520 520 show_registers(regs);
  521 + add_taint(TAINT_DIE);
521 522 /* Executive summary in case the oops scrolled away */
522 523 printk(KERN_ALERT "RIP ");
523 524 printk_address(regs->rip);
arch/xtensa/kernel/traps.c
... ... @@ -482,6 +482,7 @@
482 482 if (!user_mode(regs))
483 483 show_stack(NULL, (unsigned long*)regs->areg[1]);
484 484  
  485 + add_taint(TAINT_DIE);
485 486 spin_unlock_irq(&die_lock);
486 487  
487 488 if (in_interrupt())
include/linux/kernel.h
... ... @@ -210,6 +210,7 @@
210 210 #define TAINT_MACHINE_CHECK (1<<4)
211 211 #define TAINT_BAD_PAGE (1<<5)
212 212 #define TAINT_USER (1<<6)
  213 +#define TAINT_DIE (1<<7)
213 214  
214 215 extern void dump_stack(void);
215 216  
... ... @@ -159,14 +159,15 @@
159 159 {
160 160 static char buf[20];
161 161 if (tainted) {
162   - snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c",
  162 + snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c",
163 163 tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
164 164 tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
165 165 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
166 166 tainted & TAINT_FORCED_RMMOD ? 'R' : ' ',
167 167 tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
168 168 tainted & TAINT_BAD_PAGE ? 'B' : ' ',
169   - tainted & TAINT_USER ? 'U' : ' ');
  169 + tainted & TAINT_USER ? 'U' : ' ',
  170 + tainted & TAINT_DIE ? 'D' : ' ');
170 171 }
171 172 else
172 173 snprintf(buf, sizeof(buf), "Not tainted");