Skip to content

Commit

Permalink
Kernel: RangeAllocator randomized correctly check if size is in bound. (
Browse files Browse the repository at this point in the history
SerenityOS#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: c8e7baf
  • Loading branch information
Jorropo committed Jan 29, 2021
1 parent 51df445 commit df30b3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Kernel/VM/RangeAllocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit df30b3e

Please sign in to comment.