Browse Source

Kernel: Assert on attempt to map private region backed by shared inode

If we find ourselves with a user-accessible, non-shared Region backed by
a SharedInodeVMObject, that's pretty bad news, so let's just panic the
kernel instead of getting abused.

There might be a better place for this kind of check, so I've added a
FIXME about putting more thought into that.
Andreas Kling 4 years ago
parent
commit
3ff88a1d77
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Kernel/VM/Region.cpp

+ 6 - 0
Kernel/VM/Region.cpp

@@ -378,6 +378,12 @@ bool Region::map(PageDirectory& page_directory)
 {
     ScopedSpinLock lock(s_mm_lock);
     ScopedSpinLock page_lock(page_directory.get_lock());
+
+    // FIXME: Find a better place for this sanity check(?)
+    if (is_user_accessible() && !is_shared()) {
+        ASSERT(!vmobject().is_shared_inode());
+    }
+
     set_page_directory(page_directory);
     size_t page_index = 0;
     while (page_index < page_count()) {