Kernel: Randomize memory location of the dynamic loader :^)

This should make it a little bit harder for those who would mess with
our loader.
This commit is contained in:
Andreas Kling 2020-12-20 18:45:44 +01:00
parent 02ef3f6343
commit 34e9df3c5e
Notes: sideshowbarker 2024-07-19 00:43:29 +09:00

View file

@ -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())