summaryrefslogtreecommitdiff
path: root/Kernel/VM
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-12 19:07:47 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-12 19:15:59 +0100
commite050577f0a1729a0d34287ed990c1fab19a072e7 (patch)
tree54ebd6e695a311be9c2a1f1930e48fa4c38e7fb5 /Kernel/VM
parent4e2802bf91eab2f07896dd0b50edbd4cb19f6e3f (diff)
downloadserenity-e050577f0a1729a0d34287ed990c1fab19a072e7.zip
Kernel: Make MAP_RANDOMIZED honor alignment requests
Previously, we only cared about the alignment on the fallback path.
Diffstat (limited to 'Kernel/VM')
-rw-r--r--Kernel/VM/RangeAllocator.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/Kernel/VM/RangeAllocator.cpp b/Kernel/VM/RangeAllocator.cpp
index a3168cf1f3..c481ddfa4a 100644
--- a/Kernel/VM/RangeAllocator.cpp
+++ b/Kernel/VM/RangeAllocator.cpp
@@ -104,8 +104,7 @@ Optional<Range> RangeAllocator::allocate_randomized(size_t size, size_t alignmen
// FIXME: I'm sure there's a smarter way to do this.
static constexpr size_t maximum_randomization_attempts = 1000;
for (size_t i = 0; i < maximum_randomization_attempts; ++i) {
- VirtualAddress random_address { get_good_random<FlatPtr>() };
- random_address.mask(PAGE_MASK);
+ VirtualAddress random_address { round_up_to_power_of_two(get_good_random<FlatPtr>(), alignment) };
if (!m_total_range.contains(random_address, size))
continue;