summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeegan Saunders <keegan@undefinedbehaviour.org>2022-11-26 13:17:32 -0500
committerAndreas Kling <kling@serenityos.org>2022-11-29 11:04:21 +0100
commit89b23c473a57ddc37c316cca9b21d7a636e86d81 (patch)
tree73635c650a4b19949ca24742bf1c170864af9aba
parent675e5bfdcebb41eb172027824ad46ab056c2730e (diff)
downloadserenity-89b23c473a57ddc37c316cca9b21d7a636e86d81.zip
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.
-rw-r--r--Kernel/Arch/aarch64/init.cpp4
-rw-r--r--Kernel/Arch/x86/init.cpp6
-rw-r--r--Kernel/Prekernel/init.cpp4
-rw-r--r--Userland/Libraries/LibC/crt0.cpp2
-rw-r--r--Userland/Libraries/LibC/ssp.cpp4
-rw-r--r--Userland/Libraries/LibELF/DynamicLinker.cpp2
6 files changed, 11 insertions, 11 deletions
diff --git a/Kernel/Arch/aarch64/init.cpp b/Kernel/Arch/aarch64/init.cpp
index 4abc2826ad..de8743b511 100644
--- a/Kernel/Arch/aarch64/init.cpp
+++ b/Kernel/Arch/aarch64/init.cpp
@@ -65,8 +65,8 @@ extern ctor_func_t start_ctors[];
extern ctor_func_t end_ctors[];
// FIXME: Share this with the Intel Prekernel.
-extern size_t __stack_chk_guard;
-size_t __stack_chk_guard;
+extern uintptr_t __stack_chk_guard;
+uintptr_t __stack_chk_guard;
READONLY_AFTER_INIT bool g_in_early_boot;
diff --git a/Kernel/Arch/x86/init.cpp b/Kernel/Arch/x86/init.cpp
index 070d5da303..054955995a 100644
--- a/Kernel/Arch/x86/init.cpp
+++ b/Kernel/Arch/x86/init.cpp
@@ -68,8 +68,8 @@ extern ctor_func_t end_heap_ctors[];
extern ctor_func_t start_ctors[];
extern ctor_func_t end_ctors[];
-extern size_t __stack_chk_guard;
-READONLY_AFTER_INIT size_t __stack_chk_guard __attribute__((used));
+extern uintptr_t __stack_chk_guard;
+READONLY_AFTER_INIT uintptr_t __stack_chk_guard __attribute__((used));
extern "C" u8 start_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!
TimeManagement::initialize(0);
- __stack_chk_guard = get_fast_random<size_t>();
+ __stack_chk_guard = get_fast_random<uintptr_t>();
ProcFSComponentRegistry::initialize();
JailManagement::the();
diff --git a/Kernel/Prekernel/init.cpp b/Kernel/Prekernel/init.cpp
index 44acfcf07b..ce7476fb44 100644
--- a/Kernel/Prekernel/init.cpp
+++ b/Kernel/Prekernel/init.cpp
@@ -20,8 +20,8 @@
#endif
// Defined in the linker script
-extern size_t __stack_chk_guard;
-size_t __stack_chk_guard __attribute__((used));
+extern uintptr_t __stack_chk_guard;
+uintptr_t __stack_chk_guard __attribute__((used));
extern "C" [[noreturn]] void __stack_chk_fail();
extern "C" u8 start_of_prekernel_image[];
diff --git a/Userland/Libraries/LibC/crt0.cpp b/Userland/Libraries/LibC/crt0.cpp
index afb5cb29f8..bbac46095f 100644
--- a/Userland/Libraries/LibC/crt0.cpp
+++ b/Userland/Libraries/LibC/crt0.cpp
@@ -14,7 +14,7 @@
#ifndef _DYNAMIC_LOADER
extern "C" {
-extern size_t __stack_chk_guard;
+extern uintptr_t __stack_chk_guard;
extern bool s_global_initializers_ran;
int main(int, char**, char**);
diff --git a/Userland/Libraries/LibC/ssp.cpp b/Userland/Libraries/LibC/ssp.cpp
index edc1c3912b..8735f437d7 100644
--- a/Userland/Libraries/LibC/ssp.cpp
+++ b/Userland/Libraries/LibC/ssp.cpp
@@ -17,8 +17,8 @@
extern "C" {
-extern size_t __stack_chk_guard;
-__attribute__((used)) size_t __stack_chk_guard = (size_t)0xc6c7c8c9;
+extern uintptr_t __stack_chk_guard;
+__attribute__((used)) uintptr_t __stack_chk_guard = (uintptr_t)0xc6c7c8c9;
__attribute__((noreturn)) void __stack_chk_fail()
{
diff --git a/Userland/Libraries/LibELF/DynamicLinker.cpp b/Userland/Libraries/LibELF/DynamicLinker.cpp
index 1658d99c36..ee4ee79eac 100644
--- a/Userland/Libraries/LibELF/DynamicLinker.cpp
+++ b/Userland/Libraries/LibELF/DynamicLinker.cpp
@@ -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.
res = libc.lookup_symbol("__stack_chk_guard"sv);
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);
VERIFY(res.has_value());