diff options
author | Jorropo <jorropo.pgm@gmail.com> | 2021-01-29 17:18:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-29 17:18:23 +0100 |
commit | df30b3e54c96f83707bd4fcf6ae158888411efe7 (patch) | |
tree | 09b89723cdf18b17ed773e1e2690fba20464ab1f /Kernel/VM | |
parent | 51df44534bd6d6f32abb33c29c94600e217ad4c9 (diff) | |
download | serenity-df30b3e54c96f83707bd4fcf6ae158888411efe7.zip |
Kernel: RangeAllocator randomized correctly check if size is in bound. (#5164)
The random address proposals were not checked with the size so it was
increasely likely to try to allocate outside of available space with
larger and larger sizes.
Now they will be ignored instead of triggering a Kernel assertion
failure.
This is a continuation of: c8e7baf4b8d9da51e925d029254aaf3c8ed8c5e4
Diffstat (limited to 'Kernel/VM')
-rw-r--r-- | Kernel/VM/RangeAllocator.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/VM/RangeAllocator.cpp b/Kernel/VM/RangeAllocator.cpp index 35a4a783cc..3df97c6f1b 100644 --- a/Kernel/VM/RangeAllocator.cpp +++ b/Kernel/VM/RangeAllocator.cpp @@ -108,7 +108,7 @@ Optional<Range> RangeAllocator::allocate_randomized(size_t size, size_t alignmen VirtualAddress random_address { get_good_random<FlatPtr>() }; random_address.mask(PAGE_MASK); - if (!m_total_range.contains(random_address)) + if (!m_total_range.contains(random_address, size)) continue; auto range = allocate_specific(random_address, size); |