1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-22 19:55:07 +00:00

Kernel+LibC: Build with basic -fstack-protector support

Use simple stack cookies to try to provoke an assertion failure on
stack overflow.

This is far from perfect, since we use a constant cookie instead of
generating a random one on startup, but it can still help us catch
bugs, which is the primary concern right now. :^)
This commit is contained in:
Andreas Kling 2019-12-20 20:51:50 +01:00
parent f006e66a25
commit 842716a0b5
3 changed files with 18 additions and 1 deletions

View file

@ -183,4 +183,12 @@ void free(void* p)
{ {
return kfree(p); return kfree(p);
} }
extern u32 __stack_chk_guard;
u32 __stack_chk_guard = (u32)0xc0000c13;
[[noreturn]] void __stack_chk_fail()
{
ASSERT_NOT_REACHED();
}
} }

View file

@ -1,3 +1,4 @@
#include <AK/Types.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -51,4 +52,12 @@ int _start(int argc, char** argv, char** env)
void __cxa_atexit() void __cxa_atexit()
{ {
} }
extern u32 __stack_chk_guard;
u32 __stack_chk_guard = (u32)0xc0000c13;
[[noreturn]] void __stack_chk_fail()
{
ASSERT_NOT_REACHED();
}
} }

View file

@ -1,7 +1,7 @@
ARCH_FLAGS = ARCH_FLAGS =
STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation -fno-sized-deallocation STANDARD_FLAGS = -std=c++17 -Wno-sized-deallocation -fno-sized-deallocation
WARNING_FLAGS = -Werror -Wextra -Wall -Wno-nonnull-compare -Wno-deprecated-copy -Wno-address-of-packed-member -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-expansion-to-defined WARNING_FLAGS = -Werror -Wextra -Wall -Wno-nonnull-compare -Wno-deprecated-copy -Wno-address-of-packed-member -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-expansion-to-defined
FLAVOR_FLAGS = -fno-exceptions -fno-rtti FLAVOR_FLAGS = -fno-exceptions -fno-rtti -fstack-protector
OPTIMIZATION_FLAGS = -Os OPTIMIZATION_FLAGS = -Os
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))