Files
my-kern/kernel/util/ssp.c

30 lines
563 B
C

//
// Created by rick on 15-03-21.
//
// stack smashing protector
#include <stdint.h>
#if __STDC_HOSTED__
#include <stdlib.h>
#else
#include <myke/libk/libk.h>
#endif
#if UINT32_MAX == UINTPTR_MAX
#define STACK_CHK_GUARD 0xe2dee396
#else
#define STACK_CHK_GUARD 0x595e9fbd94fda766
#endif
// todo this value should be unique every time the kernel starts
uintptr_t __stack_chk_guard = STACK_CHK_GUARD;
void __attribute__((__noreturn__)) __stack_chk_fail(void) {
#if __STDC_HOSTED__
#error "UNKNONONO"
abort();
#else
k_panics("Stack Smashed!");
#endif
}