Skip to content

Commit 3862807

Browse files
Aaron Tomlinrostedt
authored andcommitted
tracing: Add BUG_ON when stack end location is over written
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. Link: http://lkml.kernel.org/r/1395669837-30209-1-git-send-email-atomlin@redhat.com Signed-off-by: Aaron Tomlin <atomlin@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
1 parent 0dea6d5 commit 3862807

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/trace/trace_stack.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/sysctl.h>
1414
#include <linux/init.h>
1515
#include <linux/fs.h>
16+
#include <linux/magic.h>
1617

1718
#include <asm/setup.h>
1819

@@ -144,6 +145,8 @@ check_stack(unsigned long ip, unsigned long *stack)
144145
i++;
145146
}
146147

148+
BUG_ON(current != &init_task &&
149+
*(end_of_stack(current)) != STACK_END_MAGIC);
147150
out:
148151
arch_spin_unlock(&max_stack_lock);
149152
local_irq_restore(flags);

0 commit comments

Comments
 (0)