1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 05:07:35 +00:00

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: c8e7baf4b8
This commit is contained in:
Jorropo 2021-01-29 17:18:23 +01:00 committed by GitHub
parent 51df44534b
commit df30b3e54c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

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