Selaa lähdekoodia

Kernel: Fix crash on cat /proc/PID/vmobjects

A Region starts at an offset into a VMObject, and if that offset is
non-zero, we need to subtract it from the VMObject page index here.

Fixes #2803.
Andreas Kling 5 vuotta sitten
vanhempi
commit
396291b356
1 muutettua tiedostoa jossa 4 lisäystä ja 1 poistoa
  1. 4 1
      Kernel/FileSystem/ProcFS.cpp

+ 4 - 1
Kernel/FileSystem/ProcFS.cpp

@@ -575,9 +575,12 @@ Optional<KBuffer> procfs$pid_vmobjects(InodeIdentifier identifier)
             region.vmobject().ref_count());
             region.vmobject().ref_count());
         for (size_t i = 0; i < region.vmobject().page_count(); ++i) {
         for (size_t i = 0; i < region.vmobject().page_count(); ++i) {
             auto& physical_page = region.vmobject().physical_pages()[i];
             auto& physical_page = region.vmobject().physical_pages()[i];
+            bool should_cow = false;
+            if (i >= region.first_page_index() && i <= region.last_page_index())
+                should_cow = region.should_cow(i - region.first_page_index());
             builder.appendf("P%x%s(%u) ",
             builder.appendf("P%x%s(%u) ",
                 physical_page ? physical_page->paddr().get() : 0,
                 physical_page ? physical_page->paddr().get() : 0,
-                region.should_cow(i) ? "!" : "",
+                should_cow ? "!" : "",
                 physical_page ? physical_page->ref_count() : 0);
                 physical_page ? physical_page->ref_count() : 0);
         }
         }
         builder.appendf("\n");
         builder.appendf("\n");