public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] tracing: Add BUG_ON when stack end location is over written
@ 2014-03-24 14:03 Aaron Tomlin
  2014-03-24 14:39 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: Aaron Tomlin @ 2014-03-24 14:03 UTC (permalink / raw)
  To: rostedt
  Cc: mingo, dzickus, atomlin, jgh, mguzik, pzijlstr, peterz, hpa, riel,
	linux-kernel

It is difficult to detect a stack overrun when it
actually occurs.

We have observed that this type of corruption is often
silent and can go unnoticed. Once the corrupted region
is examined, the outcome is undefined and often
results in sporadic system crashes.

When the stack tracing feature is enabled, let's check
for this condition and take appropriate action.

Note: init_task doesn't get its stack end location
set to STACK_END_MAGIC.

Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
---
 kernel/trace/trace_stack.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
index e6be585..21b320e 100644
--- a/kernel/trace/trace_stack.c
+++ b/kernel/trace/trace_stack.c
@@ -13,6 +13,7 @@
 #include <linux/sysctl.h>
 #include <linux/init.h>
 #include <linux/fs.h>
+#include <linux/magic.h>
 
 #include <asm/setup.h>
 
@@ -144,6 +145,8 @@ check_stack(unsigned long ip, unsigned long *stack)
 			i++;
 	}
 
+	BUG_ON(current != &init_task &&
+		*(end_of_stack(current)) != STACK_END_MAGIC);
  out:
 	arch_spin_unlock(&max_stack_lock);
 	local_irq_restore(flags);
-- 
1.8.5.3


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

* Re: [RFC PATCH] tracing: Add BUG_ON when stack end location is over written
  2014-03-24 14:03 [RFC PATCH] tracing: Add BUG_ON when stack end location is over written Aaron Tomlin
@ 2014-03-24 14:39 ` Steven Rostedt
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Rostedt @ 2014-03-24 14:39 UTC (permalink / raw)
  To: Aaron Tomlin
  Cc: mingo, dzickus, jgh, mguzik, pzijlstr, peterz, hpa, riel,
	linux-kernel

On Mon, 24 Mar 2014 14:03:57 +0000
Aaron Tomlin <atomlin@redhat.com> wrote:

> It is difficult to detect a stack overrun when it
> actually occurs.
> 
> We have observed that this type of corruption is often
> silent and can go unnoticed. Once the corrupted region
> is examined, the outcome is undefined and often
> results in sporadic system crashes.
> 
> When the stack tracing feature is enabled, let's check
> for this condition and take appropriate action.
> 
> Note: init_task doesn't get its stack end location
> set to STACK_END_MAGIC.
> 
> Signed-off-by: Aaron Tomlin <atomlin@redhat.com>
> ---

I added this to my 3.15 queue, and if it survives testing, I'll push it
to my for-next branch.

Thanks,

-- Steve

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

end of thread, other threads:[~2014-03-24 14:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-24 14:03 [RFC PATCH] tracing: Add BUG_ON when stack end location is over written Aaron Tomlin
2014-03-24 14:39 ` Steven Rostedt

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