Kernel: Make allocate_randomized() work for 64-bit addresses
The odds of finding a suitable address in 1000 attempts were not in our favor given the size of the 64-bit address space.
This commit is contained in:
parent
f0c4941beb
commit
357ddd393e
Notes:
sideshowbarker
2024-07-18 08:48:22 +09:00
Author: https://github.com/gunnarbeutner Commit: https://github.com/SerenityOS/serenity/commit/357ddd393eb Pull-request: https://github.com/SerenityOS/serenity/pull/8795 Reviewed-by: https://github.com/Hendiadyoin1
1 changed files with 1 additions and 1 deletions
|
@ -67,7 +67,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 { round_up_to_power_of_two(get_fast_random<FlatPtr>(), alignment) };
|
||||
VirtualAddress random_address { round_up_to_power_of_two(get_fast_random<FlatPtr>() % m_total_range.end().get(), alignment) };
|
||||
|
||||
if (!m_total_range.contains(random_address, size))
|
||||
continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue