mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-13 00:09:19 +00:00
Changed a lot of files. Summary: profiler support; "SafeFunction"; UnlockDeadLock kernel config; Code optimization & more
This commit is contained in:
@ -5,37 +5,32 @@
|
||||
|
||||
#ifndef STACK_CHK_GUARD_VALUE
|
||||
#if UINTPTR_MAX == UINT32_MAX
|
||||
#define STACK_CHK_GUARD_VALUE 0x25F6CC8D
|
||||
#define STACK_CHK_GUARD_VALUE 0xDEAD57AC
|
||||
#else
|
||||
#define STACK_CHK_GUARD_VALUE 0xBADFE2EC255A8572
|
||||
#define STACK_CHK_GUARD_VALUE 0xDEAD57AC00000000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) uintptr_t __stack_chk_guard = 0;
|
||||
|
||||
__attribute__((weak)) uintptr_t __stack_chk_guard_init(void)
|
||||
__attribute__((weak, no_stack_protector)) uintptr_t __stack_chk_guard_init(void)
|
||||
{
|
||||
return STACK_CHK_GUARD_VALUE;
|
||||
}
|
||||
|
||||
static void __attribute__((constructor, no_stack_protector)) __construct_stk_chk_guard()
|
||||
extern __attribute__((constructor, no_stack_protector)) void __guard_setup(void)
|
||||
{
|
||||
debug("StackGuard: __guard_setup");
|
||||
if (__stack_chk_guard == 0)
|
||||
__stack_chk_guard = __stack_chk_guard_init();
|
||||
}
|
||||
|
||||
// https://opensource.apple.com/source/xnu/xnu-1504.7.4/libkern/stack_protector.c.auto.html
|
||||
// static void __guard_setup(void) __attribute__((constructor));
|
||||
|
||||
// static void __guard_setup(void)
|
||||
// {
|
||||
// read_random(__stack_chk_guard, sizeof(__stack_chk_guard));
|
||||
// }
|
||||
|
||||
__attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fail(void)
|
||||
{
|
||||
TaskingPanic();
|
||||
error("Stack smashing detected!");
|
||||
for (short i = 0; i < 10; i++)
|
||||
error("Stack smashing detected!");
|
||||
debug("%#lx", __stack_chk_guard);
|
||||
KPrint("\eFF0000Stack smashing detected!");
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
while (1)
|
||||
@ -49,7 +44,8 @@ __attribute__((weak, noreturn, no_stack_protector)) void __stack_chk_fail(void)
|
||||
__attribute__((weak, noreturn, no_stack_protector)) void __chk_fail(void)
|
||||
{
|
||||
TaskingPanic();
|
||||
error("Buffer overflow detected!");
|
||||
for (short i = 0; i < 10; i++)
|
||||
error("Buffer overflow detected!");
|
||||
KPrint("\eFF0000Buffer overflow detected!");
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
while (1)
|
||||
|
Reference in New Issue
Block a user