From 0e8081d8e9db8b9482da7e92a72194bfa927223d Mon Sep 17 00:00:00 2001 From: Danny Holman Date: Fri, 21 Jun 2024 23:32:18 -0500 Subject: libk: use a random value for the stack protector Don't hardcode the __stack_chk_guard value, generate a random value (using RDRAND on x86) before running any C code. Signed-off-by: Danny Holman --- libk/stack_protector.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'libk/stack_protector.c') diff --git a/libk/stack_protector.c b/libk/stack_protector.c index 78d0302..a929ae0 100644 --- a/libk/stack_protector.c +++ b/libk/stack_protector.c @@ -1,11 +1,9 @@ #include #include -#include -#define STACK_CHK_GUARD 0x32E3429E - -uintptr_t __stack_chk_guard = STACK_CHK_GUARD; +uintptr_t __stack_chk_guard; __attribute__((noreturn)) void __stack_chk_fail(void) { - panic("STACK SMASHING IN KERNEL ADDRESS SPACE"); + panic("Detected attempted stack manipulation in kernel"); + while(1); } -- cgit v1.2.3