public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Taint kernel after WARN_ON(condition) v2
@ 2008-02-13 14:27 Nur Hussein
  2008-02-13 14:55 ` Haavard Skinnemoen
  0 siblings, 1 reply; 5+ messages in thread
From: Nur Hussein @ 2008-02-13 14:27 UTC (permalink / raw)
  To: linux-kernel
  Cc: randy.dunlap, arjan, akpm, mingo, a.p.zijlstra, kyle, schwidefsky,
	hskinnemoen, lethal

Here's an improved version of the patch I sent previously, taking into
account the comments given.

The kernel is sent to tainted within the warn_on_slowpath() function,
and whenever a warning occurs the new taint flag 'W' is set. This is
useful to know if a warning occurred before a BUG by preserving the
warning as a flag in the taint state.

This does not work on architectures where WARN_ON has its own definition. 
These archs are:
	1. s390
	2. superh
	3. avr32
	4. parisc

The maintainers of these architectures have been added in the Cc: list
in this email to alert them to the situation.

The documentation in oops-tracing.txt has been updated to include the
new flag.

Signed-off-by: Nur Hussein <nurhussein@gmail.com>

--

diff --git a/Documentation/oops-tracing.txt b/Documentation/oops-tracing.txt
index 7f60dfe..b152e81 100644
--- a/Documentation/oops-tracing.txt
+++ b/Documentation/oops-tracing.txt
@@ -253,6 +253,10 @@ characters, each representing a particular tainted value.
 
   8: 'D' if the kernel has died recently, i.e. there was an OOPS or BUG.
 
+  9: 'A' if the ACPI table has been overridden.
+
+ 10: 'W' if a warning has previously been issued by the kernel.
+
 The primary reason for the 'Tainted: ' string is to tell kernel
 debuggers if this is a clean kernel or if anything unusual has
 occurred.  Tainting is permanent: even if an offending module is
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 2df44e7..d90c1a4 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -255,6 +255,7 @@ extern enum system_states {
 #define TAINT_USER			(1<<6)
 #define TAINT_DIE			(1<<7)
 #define TAINT_OVERRIDDEN_ACPI_TABLE	(1<<8)
+#define TAINT_WARN			(1<<9)
 
 extern void dump_stack(void) __cold;
 
diff --git a/kernel/panic.c b/kernel/panic.c
index 24af9f8..425567f 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -153,6 +153,8 @@ EXPORT_SYMBOL(panic);
  *  'M' - System experienced a machine check exception.
  *  'B' - System has hit bad_page.
  *  'U' - Userspace-defined naughtiness.
+ *  'A' - ACPI table overridden.
+ *  'W' - Taint on warning.
  *
  *	The string is overwritten by the next call to print_taint().
  */
@@ -161,7 +163,7 @@ const char *print_tainted(void)
 {
 	static char buf[20];
 	if (tainted) {
-		snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c",
+		snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c",
 			tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
 			tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
 			tainted & TAINT_UNSAFE_SMP ? 'S' : ' ',
@@ -170,7 +172,8 @@ const char *print_tainted(void)
 			tainted & TAINT_BAD_PAGE ? 'B' : ' ',
 			tainted & TAINT_USER ? 'U' : ' ',
 			tainted & TAINT_DIE ? 'D' : ' ',
-			tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ');
+			tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ',
+			tainted & TAINT_WARN ? 'W' : ' ');
 	}
 	else
 		snprintf(buf, sizeof(buf), "Not tainted");
@@ -312,6 +315,7 @@ void warn_on_slowpath(const char *file, int line)
 	print_modules();
 	dump_stack();
 	print_oops_end_marker();
+	add_taint(TAINT_WARN);
 }
 EXPORT_SYMBOL(warn_on_slowpath);
 #endif

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Taint kernel after WARN_ON(condition) v2
  2008-02-13 14:27 Taint kernel after WARN_ON(condition) v2 Nur Hussein
@ 2008-02-13 14:55 ` Haavard Skinnemoen
  2008-05-15  4:06   ` Paul Mundt
  0 siblings, 1 reply; 5+ messages in thread
From: Haavard Skinnemoen @ 2008-02-13 14:55 UTC (permalink / raw)
  To: Nur Hussein
  Cc: linux-kernel, randy.dunlap, arjan, akpm, mingo, a.p.zijlstra,
	kyle, schwidefsky, lethal

On Wed, 13 Feb 2008 22:27:40 +0800
Nur Hussein <nurhussein@gmail.com> wrote:

> This does not work on architectures where WARN_ON has its own definition. 
> These archs are:
> 	1. s390
> 	2. superh
> 	3. avr32
> 	4. parisc

Hmm. Relying on the generic code in lib/bug.c qualifies as "own
definition" these days? I think the patch below should take care of all
four...unless I've misunderstood something.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>

diff --git a/lib/bug.c b/lib/bug.c
index 530f38f..0d67419 100644
--- a/lib/bug.c
+++ b/lib/bug.c
@@ -35,6 +35,7 @@
 
     Jeremy Fitzhardinge <jeremy@goop.org> 2006
  */
+#include <linux/kernel.h>
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/bug.h>
@@ -149,6 +150,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
 			       (void *)bugaddr);
 
 		show_regs(regs);
+		add_taint(TAINT_WARN);
 		return BUG_TRAP_TYPE_WARN;
 	}
 

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Taint kernel after WARN_ON(condition) v2
  2008-02-13 14:55 ` Haavard Skinnemoen
@ 2008-05-15  4:06   ` Paul Mundt
  2008-05-15 23:51     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Paul Mundt @ 2008-05-15  4:06 UTC (permalink / raw)
  To: Haavard Skinnemoen
  Cc: Nur Hussein, linux-kernel, randy.dunlap, arjan, akpm, mingo,
	a.p.zijlstra, kyle, schwidefsky

On Wed, Feb 13, 2008 at 03:55:20PM +0100, Haavard Skinnemoen wrote:
> On Wed, 13 Feb 2008 22:27:40 +0800
> Nur Hussein <nurhussein@gmail.com> wrote:
> 
> > This does not work on architectures where WARN_ON has its own definition. 
> > These archs are:
> > 	1. s390
> > 	2. superh
> > 	3. avr32
> > 	4. parisc
> 
> Hmm. Relying on the generic code in lib/bug.c qualifies as "own
> definition" these days? I think the patch below should take care of all
> four...unless I've misunderstood something.
> 
> Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
> 
> diff --git a/lib/bug.c b/lib/bug.c
> index 530f38f..0d67419 100644
> --- a/lib/bug.c
> +++ b/lib/bug.c
> @@ -35,6 +35,7 @@
>  
>      Jeremy Fitzhardinge <jeremy@goop.org> 2006
>   */
> +#include <linux/kernel.h>
>  #include <linux/list.h>
>  #include <linux/module.h>
>  #include <linux/bug.h>
> @@ -149,6 +150,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
>  			       (void *)bugaddr);
>  
>  		show_regs(regs);
> +		add_taint(TAINT_WARN);
>  		return BUG_TRAP_TYPE_WARN;
>  	}
>  

I was just about to submit the exact same patch, so it looks like this
slipped through the cracks. Andrew, please apply.

Acked-by: Paul Mundt <lethal@linux-sh.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Taint kernel after WARN_ON(condition) v2
  2008-05-15  4:06   ` Paul Mundt
@ 2008-05-15 23:51     ` Andrew Morton
  2008-05-16  4:51       ` Paul Mundt
  0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2008-05-15 23:51 UTC (permalink / raw)
  To: Paul Mundt
  Cc: hskinnemoen, nurhussein, linux-kernel, randy.dunlap, arjan, mingo,
	a.p.zijlstra, kyle, schwidefsky

On Thu, 15 May 2008 13:06:35 +0900
Paul Mundt <lethal@linux-sh.org> wrote:

> On Wed, Feb 13, 2008 at 03:55:20PM +0100, Haavard Skinnemoen wrote:
> > On Wed, 13 Feb 2008 22:27:40 +0800
> > Nur Hussein <nurhussein@gmail.com> wrote:
> > 
> > > This does not work on architectures where WARN_ON has its own definition. 
> > > These archs are:
> > > 	1. s390
> > > 	2. superh
> > > 	3. avr32
> > > 	4. parisc
> > 
> > Hmm. Relying on the generic code in lib/bug.c qualifies as "own
> > definition" these days? I think the patch below should take care of all
> > four...unless I've misunderstood something.
> > 
> > Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
> > 
> > diff --git a/lib/bug.c b/lib/bug.c
> > index 530f38f..0d67419 100644
> > --- a/lib/bug.c
> > +++ b/lib/bug.c
> > @@ -35,6 +35,7 @@
> >  
> >      Jeremy Fitzhardinge <jeremy@goop.org> 2006
> >   */
> > +#include <linux/kernel.h>
> >  #include <linux/list.h>
> >  #include <linux/module.h>
> >  #include <linux/bug.h>
> > @@ -149,6 +150,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
> >  			       (void *)bugaddr);
> >  
> >  		show_regs(regs);
> > +		add_taint(TAINT_WARN);
> >  		return BUG_TRAP_TYPE_WARN;
> >  	}
> >  
> 
> I was just about to submit the exact same patch, so it looks like this
> slipped through the cracks. Andrew, please apply.

<goes dumpster-diving through lkml history>

> Acked-by: Paul Mundt <lethal@linux-sh.org>

I'd have ducked that one partly because of lack of changelog but mainly
because it didn't look like anyone tested it.

It's hard to see how it could go wrong, but stranger things have
happened.  To me.  Regularly :(



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Taint kernel after WARN_ON(condition) v2
  2008-05-15 23:51     ` Andrew Morton
@ 2008-05-16  4:51       ` Paul Mundt
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Mundt @ 2008-05-16  4:51 UTC (permalink / raw)
  To: Andrew Morton
  Cc: hskinnemoen, nurhussein, linux-kernel, randy.dunlap, arjan, mingo,
	a.p.zijlstra, kyle, schwidefsky

On Thu, May 15, 2008 at 04:51:34PM -0700, Andrew Morton wrote:
> On Thu, 15 May 2008 13:06:35 +0900
> Paul Mundt <lethal@linux-sh.org> wrote:
> 
> > On Wed, Feb 13, 2008 at 03:55:20PM +0100, Haavard Skinnemoen wrote:
> > > On Wed, 13 Feb 2008 22:27:40 +0800
> > > Nur Hussein <nurhussein@gmail.com> wrote:
> > > 
> > > > This does not work on architectures where WARN_ON has its own definition. 
> > > > These archs are:
> > > > 	1. s390
> > > > 	2. superh
> > > > 	3. avr32
> > > > 	4. parisc
> > > 
> > > Hmm. Relying on the generic code in lib/bug.c qualifies as "own
> > > definition" these days? I think the patch below should take care of all
> > > four...unless I've misunderstood something.
> > > 
> > > Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
> > > 
> > > diff --git a/lib/bug.c b/lib/bug.c
> > > index 530f38f..0d67419 100644
> > > --- a/lib/bug.c
> > > +++ b/lib/bug.c
> > > @@ -35,6 +35,7 @@
> > >  
> > >      Jeremy Fitzhardinge <jeremy@goop.org> 2006
> > >   */
> > > +#include <linux/kernel.h>
> > >  #include <linux/list.h>
> > >  #include <linux/module.h>
> > >  #include <linux/bug.h>
> > > @@ -149,6 +150,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
> > >  			       (void *)bugaddr);
> > >  
> > >  		show_regs(regs);
> > > +		add_taint(TAINT_WARN);
> > >  		return BUG_TRAP_TYPE_WARN;
> > >  	}
> > >  
> > 
> > I was just about to submit the exact same patch, so it looks like this
> > slipped through the cracks. Andrew, please apply.
> 
> <goes dumpster-diving through lkml history>
> 
> > Acked-by: Paul Mundt <lethal@linux-sh.org>
> 
> I'd have ducked that one partly because of lack of changelog but mainly
> because it didn't look like anyone tested it.
> 
> It's hard to see how it could go wrong, but stranger things have
> happened.  To me.  Regularly :(
> 
It will work on any platform that implements warning traps through the
report_bug() path (ie, both report_bug() calling and BUG_TRAP_TYPE_WARN
checking), which is all of the platforms listed by Nur in his initial
comment as well as powerpc. And it's at least been verified on avr32 and
sh.

Either Havaard or I can resubmit this with a proper changelog if that
will help move things along, obviously it's not a very pressing patch one
way or the other, but consistency is good, and we're all likely to forget
about this again otherwise.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-05-16  4:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-13 14:27 Taint kernel after WARN_ON(condition) v2 Nur Hussein
2008-02-13 14:55 ` Haavard Skinnemoen
2008-05-15  4:06   ` Paul Mundt
2008-05-15 23:51     ` Andrew Morton
2008-05-16  4:51       ` Paul Mundt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox