mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:07:35 +00:00
LibC: Use uintptr_t for __stack_chk_guard
We used size_t, which is a type that is guarenteed to be large enough to hold an array index, but uintptr_t is designed to be used to hold pointer values, which is the case of stack guards.
This commit is contained in:
parent
675e5bfdce
commit
89b23c473a
6 changed files with 11 additions and 11 deletions
|
@ -65,8 +65,8 @@ extern ctor_func_t start_ctors[];
|
||||||
extern ctor_func_t end_ctors[];
|
extern ctor_func_t end_ctors[];
|
||||||
|
|
||||||
// FIXME: Share this with the Intel Prekernel.
|
// FIXME: Share this with the Intel Prekernel.
|
||||||
extern size_t __stack_chk_guard;
|
extern uintptr_t __stack_chk_guard;
|
||||||
size_t __stack_chk_guard;
|
uintptr_t __stack_chk_guard;
|
||||||
|
|
||||||
READONLY_AFTER_INIT bool g_in_early_boot;
|
READONLY_AFTER_INIT bool g_in_early_boot;
|
||||||
|
|
||||||
|
|
|
@ -68,8 +68,8 @@ extern ctor_func_t end_heap_ctors[];
|
||||||
extern ctor_func_t start_ctors[];
|
extern ctor_func_t start_ctors[];
|
||||||
extern ctor_func_t end_ctors[];
|
extern ctor_func_t end_ctors[];
|
||||||
|
|
||||||
extern size_t __stack_chk_guard;
|
extern uintptr_t __stack_chk_guard;
|
||||||
READONLY_AFTER_INIT size_t __stack_chk_guard __attribute__((used));
|
READONLY_AFTER_INIT uintptr_t __stack_chk_guard __attribute__((used));
|
||||||
|
|
||||||
extern "C" u8 start_of_safemem_text[];
|
extern "C" u8 start_of_safemem_text[];
|
||||||
extern "C" u8 end_of_safemem_text[];
|
extern "C" u8 end_of_safemem_text[];
|
||||||
|
@ -234,7 +234,7 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init(BootInfo const& boot_info)
|
||||||
// Initialize TimeManagement before using randomness!
|
// Initialize TimeManagement before using randomness!
|
||||||
TimeManagement::initialize(0);
|
TimeManagement::initialize(0);
|
||||||
|
|
||||||
__stack_chk_guard = get_fast_random<size_t>();
|
__stack_chk_guard = get_fast_random<uintptr_t>();
|
||||||
|
|
||||||
ProcFSComponentRegistry::initialize();
|
ProcFSComponentRegistry::initialize();
|
||||||
JailManagement::the();
|
JailManagement::the();
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Defined in the linker script
|
// Defined in the linker script
|
||||||
extern size_t __stack_chk_guard;
|
extern uintptr_t __stack_chk_guard;
|
||||||
size_t __stack_chk_guard __attribute__((used));
|
uintptr_t __stack_chk_guard __attribute__((used));
|
||||||
extern "C" [[noreturn]] void __stack_chk_fail();
|
extern "C" [[noreturn]] void __stack_chk_fail();
|
||||||
|
|
||||||
extern "C" u8 start_of_prekernel_image[];
|
extern "C" u8 start_of_prekernel_image[];
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#ifndef _DYNAMIC_LOADER
|
#ifndef _DYNAMIC_LOADER
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
extern size_t __stack_chk_guard;
|
extern uintptr_t __stack_chk_guard;
|
||||||
extern bool s_global_initializers_ran;
|
extern bool s_global_initializers_ran;
|
||||||
|
|
||||||
int main(int, char**, char**);
|
int main(int, char**, char**);
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
extern size_t __stack_chk_guard;
|
extern uintptr_t __stack_chk_guard;
|
||||||
__attribute__((used)) size_t __stack_chk_guard = (size_t)0xc6c7c8c9;
|
__attribute__((used)) uintptr_t __stack_chk_guard = (uintptr_t)0xc6c7c8c9;
|
||||||
|
|
||||||
__attribute__((noreturn)) void __stack_chk_fail()
|
__attribute__((noreturn)) void __stack_chk_fail()
|
||||||
{
|
{
|
||||||
|
|
|
@ -258,7 +258,7 @@ static void initialize_libc(DynamicObject& libc)
|
||||||
// This is not done in __libc_init, as we definitely have to return from that, and it might affect Loader as well.
|
// This is not done in __libc_init, as we definitely have to return from that, and it might affect Loader as well.
|
||||||
res = libc.lookup_symbol("__stack_chk_guard"sv);
|
res = libc.lookup_symbol("__stack_chk_guard"sv);
|
||||||
VERIFY(res.has_value());
|
VERIFY(res.has_value());
|
||||||
arc4random_buf(res.value().address.as_ptr(), sizeof(size_t));
|
arc4random_buf(res.value().address.as_ptr(), sizeof(uintptr_t));
|
||||||
|
|
||||||
res = libc.lookup_symbol("__environ_is_malloced"sv);
|
res = libc.lookup_symbol("__environ_is_malloced"sv);
|
||||||
VERIFY(res.has_value());
|
VERIFY(res.has_value());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue