summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kernel.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/kernel/kernel.c b/kernel/kernel.c
index 59ad130..77970c3 100644
--- a/kernel/kernel.c
+++ b/kernel/kernel.c
@@ -31,6 +31,27 @@
#include "task.h"
+#include <stdint.h>
+#include <stdlib.h>
+
+
+// CODE FOR Stack Smashing Protector, TODO: MOVE / and do not duplicate
+// with sys.c
+// http://wiki.osdev.org/Stack_Smashing_Protector
+
+#if UINT32_MAX == UINTPTR_MAX
+#define STACK_CHK_GUARD 0xe2dee396
+#else
+#define STACK_CHK_GUARD 0x595e9fbd94fda766
+#endif
+
+uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
+
+__attribute__((noreturn))
+void __stack_chk_fail(void)
+{
+ panic(FOOLOS_MODULE_NAME,"Stack smashing detected");
+}
// mp informs us if this if this is the main processor
void kernel_main(uint32_t initial_stack, int mp)