Kernel: Don't request a random u32 when all but 5 bits are immediately masked off

This commit is contained in:
Nico Weber 2020-08-13 12:30:39 -04:00 committed by Andreas Kling
parent 924951e426
commit 6e1d6d1ff5
Notes: sideshowbarker 2024-07-19 03:40:45 +09:00

View File

@ -80,7 +80,7 @@ PageDirectory::PageDirectory(Process& process, const RangeAllocator* parent_rang
if (parent_range_allocator) {
m_range_allocator.initialize_from_parent(*parent_range_allocator);
} else {
size_t random_offset = (get_fast_random<u32>() % 32 * MB) & PAGE_MASK;
size_t random_offset = (get_fast_random<u8>() % 32 * MB) & PAGE_MASK;
u32 base = userspace_range_base + random_offset;
m_range_allocator.initialize_with_range(VirtualAddress(base), userspace_range_ceiling - base);
}