From bf43d94a2f0fc761158b0049e97fb69d8d273c8c Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 5 Sep 2019 11:13:10 +0200 Subject: [PATCH] Kernel: Disable interrupts throughout ~Region() We don't want an interrupt handler to access the VM data structures while their internal consistency is broken. --- Kernel/VM/Region.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 31cbda862c..6e778e5197 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -39,6 +39,10 @@ Region::Region(const Range& range, NonnullRefPtr 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);