xref: /haiku/src/system/kernel/lib/stack_protector.cpp (revision e1c4049fed1047bdb957b0529e1921e97ef94770)
1 /*
2  * Copyright 2021, Jérôme Duval, jerome.duval@gmail.com.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 
7 #include <sys/cdefs.h>
8 
9 #include <SupportDefs.h>
10 
11 #include <util/Random.h>
12 
13 
14 extern "C" {
15 
16 long __stack_chk_guard;
17 
18 
19 void
20 __stack_chk_fail()
21 {
22 	panic("stack smashing detected\n");
23 }
24 
25 
26 }
27 
28 
29 void
30 stack_protector_init()
31 {
32 	__stack_chk_guard = secure_get_random<long>();
33 }
34 
35