Browse Source

Kernel: Sanity check the VM range when constructing a Region

This should help us catch bogus VM ranges ending up in a process's
address space sooner.
Andreas Kling 4 years ago
parent
commit
a5def4e98c
1 changed files with 4 additions and 0 deletions
  1. 4 0
      Kernel/VM/Region.cpp

+ 4 - 0
Kernel/VM/Region.cpp

@@ -49,6 +49,10 @@ Region::Region(const Range& range, NonnullRefPtr<VMObject> vmobject, size_t offs
     , m_cacheable(cacheable)
     , m_kernel(kernel)
 {
+    ASSERT(m_range.base().is_page_aligned());
+    ASSERT(m_range.size());
+    ASSERT((m_range.size() % PAGE_SIZE) == 0);
+
     m_vmobject->ref_region();
     register_purgeable_page_ranges();
     MM.register_region(*this);