浏览代码

Kernel: Disable interrupts throughout ~Region()

We don't want an interrupt handler to access the VM data structures
while their internal consistency is broken.
Andreas Kling 5 年之前
父节点
当前提交
bf43d94a2f
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      Kernel/VM/Region.cpp

+ 4 - 0
Kernel/VM/Region.cpp

@@ -39,6 +39,10 @@ Region::Region(const Range& range, NonnullRefPtr<VMObject> vmo, size_t offset_in
 
 Region::~Region()
 {
+    // Make sure we disable interrupts so we don't get interrupted between unmapping and unregistering.
+    // Unmapping the region will give the VM back to the RangeAllocator, so an interrupt handler would
+    // find the address<->region mappings in an invalid state there.
+    InterruptDisabler disabler;
     if (m_page_directory) {
         MM.unmap_region(*this);
         ASSERT(!m_page_directory);