diff options
author | Idan Horowitz <idan.horowitz@ibm.com> | 2022-03-22 19:10:17 +0200 |
---|---|---|
committer | Idan Horowitz <idan.horowitz@gmail.com> | 2022-03-23 19:49:49 +0200 |
commit | f0166efe8c92359079dcff1e077e9e1615260007 (patch) | |
tree | 22e7c21e451c93939fc8a7c99612df394525d164 /Kernel/Prekernel | |
parent | e0c77279341f02698a11dc600a8c80ebaf6762f5 (diff) | |
download | serenity-f0166efe8c92359079dcff1e077e9e1615260007.zip |
Kernel: Use the whole kernel PD range when randomizing the KASLR offset
Now that we reclaim the memory range that is created by KASLR before
the start of the kernel image, there's no need to be conservative with
the KASLR offset.
Diffstat (limited to 'Kernel/Prekernel')
-rw-r--r-- | Kernel/Prekernel/Prekernel.h | 2 | ||||
-rw-r--r-- | Kernel/Prekernel/init.cpp | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/Kernel/Prekernel/Prekernel.h b/Kernel/Prekernel/Prekernel.h index b01f5eeb66..f237286e2f 100644 --- a/Kernel/Prekernel/Prekernel.h +++ b/Kernel/Prekernel/Prekernel.h @@ -13,6 +13,7 @@ #endif #define MAX_KERNEL_SIZE 0x4000000 +#define KERNEL_PD_SIZE 0x31000000 #ifdef __cplusplus namespace Kernel { @@ -22,7 +23,6 @@ struct [[gnu::packed]] BootInfo { u32 end_of_prekernel_image; u64 physical_to_virtual_offset; u64 kernel_mapping_base; - u64 default_kernel_load_base; u64 kernel_load_base; # if ARCH(X86_64) u32 gdt64ptr; diff --git a/Kernel/Prekernel/init.cpp b/Kernel/Prekernel/init.cpp index 3692998cfc..26a4c4d95a 100644 --- a/Kernel/Prekernel/init.cpp +++ b/Kernel/Prekernel/init.cpp @@ -97,7 +97,7 @@ extern "C" [[noreturn]] void init() #endif // KASLR - static constexpr auto maximum_offset = 256 * MiB; + FlatPtr maximum_offset = (FlatPtr)KERNEL_PD_SIZE - MAX_KERNEL_SIZE - 2 * MiB; // The first 2 MiB are used for mapping the pre-kernel FlatPtr kernel_load_base = default_kernel_load_base + (generate_secure_seed() % maximum_offset); kernel_load_base &= ~(2 * MiB - 1); @@ -184,7 +184,6 @@ extern "C" [[noreturn]] void init() info.end_of_prekernel_image = (PhysicalPtr)end_of_prekernel_image; info.physical_to_virtual_offset = kernel_load_base - kernel_physical_base; info.kernel_mapping_base = kernel_mapping_base; - info.default_kernel_load_base = default_kernel_load_base; info.kernel_load_base = kernel_load_base; #if ARCH(X86_64) info.gdt64ptr = (PhysicalPtr)gdt64ptr; |