Ver código fonte

Kernel: Fix overly loose MemoryManager::kernel_region_from_vaddr()

It's not enough to just find the largest-address-not-above the argument,
we must also check that the found region actually contains the argument.

Regressed in a23edd42b869a16e11f4d6ca9071d6b570dc219c, thanks to Idan
for pointing this out.
Andreas Kling 3 anos atrás
pai
commit
813593a485
1 arquivos alterados com 1 adições e 1 exclusões
  1. 1 1
      Kernel/Memory/MemoryManager.cpp

+ 1 - 1
Kernel/Memory/MemoryManager.cpp

@@ -623,7 +623,7 @@ Region* MemoryManager::kernel_region_from_vaddr(VirtualAddress vaddr)
     auto* region_ptr = MM.m_kernel_regions.find_largest_not_above(vaddr.get());
     if (!region_ptr)
         return nullptr;
-    return *region_ptr;
+    return (*region_ptr)->contains(vaddr) ? *region_ptr : nullptr;
 }
 
 Region* MemoryManager::find_user_region_from_vaddr_no_lock(AddressSpace& space, VirtualAddress vaddr)