Implement Stack Smashing Protection
This commit is contained in:
18
kernel/kernel/ssp.c
Normal file
18
kernel/kernel/ssp.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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)
|
||||
{
|
||||
printf("Stack smashing detected\n");
|
||||
abort();
|
||||
}
|
||||
Reference in New Issue
Block a user