2021-01-01 15:27:42 -08:00
|
|
|
/*
|
2021-04-22 12:11:04 -07:00
|
|
|
* Copyright (c) 2021, Brian Gianforcaro <bgianf@serenityos.org>
|
2021-01-01 15:27:42 -08:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-01-01 15:27:42 -08:00
|
|
|
*/
|
|
|
|
|
|
2021-02-17 15:48:55 +01:00
|
|
|
#include <AK/Format.h>
|
2021-01-01 15:27:42 -08:00
|
|
|
#include <AK/Types.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <sys/internals.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
#if defined __SSP__ || defined __SSP_ALL__
|
|
|
|
|
# error "file must not be compiled with stack protection enabled on it. Use -fno-stack-protector"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
2022-11-26 13:17:32 -05:00
|
|
|
extern uintptr_t __stack_chk_guard;
|
2024-01-20 16:20:42 -05:00
|
|
|
// Populated by DynamicLinker in shared executables.
|
|
|
|
|
[[gnu::weak]] uintptr_t __stack_chk_guard = (uintptr_t)0xc6c7c8c9;
|
2021-01-01 15:27:42 -08:00
|
|
|
|
2021-06-29 10:31:48 +02:00
|
|
|
__attribute__((noreturn)) void __stack_chk_fail()
|
2021-01-01 15:27:42 -08:00
|
|
|
{
|
2021-02-17 15:48:55 +01:00
|
|
|
dbgln("Error: USERSPACE({}) Stack protector failure, stack smashing detected!", getpid());
|
2021-01-01 15:27:42 -08:00
|
|
|
if (__stdio_is_initialized)
|
2021-02-17 15:48:55 +01:00
|
|
|
warnln("Error: Stack protector failure, stack smashing detected!");
|
2021-01-01 15:27:42 -08:00
|
|
|
abort();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // extern "C"
|