From 34e9df3c5e41c923faf518f45e8302e997021d4b Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 20 Dec 2020 18:45:44 +0100 Subject: [PATCH] Kernel: Randomize memory location of the dynamic loader :^) This should make it a little bit harder for those who would mess with our loader. --- Kernel/Syscalls/execve.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 4afadb1576..581e283e0e 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -188,8 +188,9 @@ int Process::load(NonnullRefPtr main_program_description, RefPt return 0; } - // TODO: This should be randomized for ASLR - constexpr FlatPtr interpreter_load_offset = 0x08000000; + // TODO: I'm sure this can be randomized even better. :^) + FlatPtr random_offset = get_good_random() * PAGE_SIZE; + FlatPtr interpreter_load_offset = 0x08000000 + random_offset; auto interpreter_load_result = load_elf_object(*interpreter_description, interpreter_load_offset, ShouldAllocateTls::No); if (interpreter_load_result.is_error())