summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-20 18:45:44 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-20 18:49:24 +0100
commit34e9df3c5e41c923faf518f45e8302e997021d4b (patch)
tree6cd72077ff3ce4e128fb7b5d62e64c99dfa70397 /Kernel
parent02ef3f6343a82bf16202db82d176fb78d35a69de (diff)
downloadserenity-34e9df3c5e41c923faf518f45e8302e997021d4b.zip
Kernel: Randomize memory location of the dynamic loader :^)
This should make it a little bit harder for those who would mess with our loader.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/Syscalls/execve.cpp5
1 files 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<FileDescription> 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<u16>() * 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())