summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2020-01-06 13:05:40 +0100
committerAndreas Kling <awesomekling@gmail.com>2020-01-06 13:05:40 +0100
commit99f71a9a2cdcbcf5f376dc482a833a1510fb41f2 (patch)
tree2a6324af8339190eb8898cb79fd5867b853e13a3 /Kernel
parent0614c3dd3c41d91fb72bc421dd10325e17c82fc0 (diff)
downloadserenity-99f71a9a2cdcbcf5f376dc482a833a1510fb41f2.zip
Kernel: Randomize the stack canary on startup
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/StdLib.cpp3
-rw-r--r--Kernel/init.cpp6
2 files changed, 6 insertions, 3 deletions
diff --git a/Kernel/StdLib.cpp b/Kernel/StdLib.cpp
index 8407882089..bbc4a8b347 100644
--- a/Kernel/StdLib.cpp
+++ b/Kernel/StdLib.cpp
@@ -213,9 +213,6 @@ void free(void* p)
return kfree(p);
}
-extern u32 __stack_chk_guard;
-u32 __stack_chk_guard = (u32)0xc0000c13;
-
[[noreturn]] void __stack_chk_fail()
{
ASSERT_NOT_REACHED();
diff --git a/Kernel/init.cpp b/Kernel/init.cpp
index b01d496abe..b7df3d8691 100644
--- a/Kernel/init.cpp
+++ b/Kernel/init.cpp
@@ -44,6 +44,7 @@
#include <Kernel/Net/RTL8139NetworkAdapter.h>
#include <Kernel/PCI/Access.h>
#include <Kernel/PCI/Initializer.h>
+#include <Kernel/Random.h>
#include <Kernel/TTY/PTYMultiplexer.h>
#include <Kernel/TTY/VirtualConsole.h>
#include <Kernel/VM/MemoryManager.h>
@@ -219,6 +220,9 @@ extern "C" int __cxa_atexit(void (*)(void*), void*, void*)
return 0;
}
+extern u32 __stack_chk_guard;
+u32 __stack_chk_guard;
+
extern "C" [[noreturn]] void init(u32 physical_address_for_kernel_page_tables)
{
// this is only used one time, directly below here. we can't use this part
@@ -313,6 +317,8 @@ extern "C" [[noreturn]] void init(u32 physical_address_for_kernel_page_tables)
kprintf("x86: No RDRAND support detected. Randomness will be shitty\n");
}
+ __stack_chk_guard = get_good_random<u32>();
+
RTC::initialize();
PIC::initialize();
gdt_init();