From df30b3e54c96f83707bd4fcf6ae158888411efe7 Mon Sep 17 00:00:00 2001 From: Jorropo Date: Fri, 29 Jan 2021 17:18:23 +0100 Subject: [PATCH] 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 --- Kernel/VM/RangeAllocator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 RangeAllocator::allocate_randomized(size_t size, size_t alignmen VirtualAddress random_address { get_good_random() }; 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);