1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 18:27:35 +00:00

Kernel: Make Region's physical page accessors safer to use

Region::physical_page() now takes the VMObject lock while accessing the
physical pages array, and returns a RefPtr<PhysicalPage>. This ensures
that the array access is safe.

Region::physical_page_slot() now VERIFY()'s that the VMObject lock is
held by the caller. Since we're returning a reference to the physical
page slot in the VMObject's physical page array, this is the best we
can do here.
This commit is contained in:
Andreas Kling 2022-08-18 19:20:33 +02:00
parent c3ad4ffcec
commit 4bc3745ce6
4 changed files with 12 additions and 9 deletions

View file

@ -293,7 +293,7 @@ ErrorOr<void> Process::procfs_get_virtual_memory_stats(KBufferBuilder& builder)
StringBuilder pagemap_builder;
for (size_t i = 0; i < region.page_count(); ++i) {
auto const* page = region.physical_page(i);
auto page = region.physical_page(i);
if (!page)
pagemap_builder.append('N');
else if (page->is_shared_zero_page() || page->is_lazy_committed_page())