mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 14:38:11 +00:00
Kernel: Mape quickmap functions VERIFY that MM lock is held
The quickmap_page() and unquickmap_page() functions are used to map a single physical page at a kernel virtual address for temporary access. These use the per-CPU quickmap buffer in the page tables, and access to this is guarded by the MM lock. To prevent bugs, quickmap_page() should not *take* the MM lock, but rather verify that it is already held! This exposed two situations where we were using quickmap without holding the MM lock during page fault handling. This patch is forced to fix these issues (which is great!) :^)
This commit is contained in:
parent
1b9916439f
commit
a930877f31
3 changed files with 11 additions and 7 deletions
|
@ -451,9 +451,12 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region)
|
|||
return PageFaultResponse::OutOfMemory;
|
||||
}
|
||||
|
||||
u8* dest_ptr = MM.quickmap_page(*vmobject_physical_page_entry);
|
||||
memcpy(dest_ptr, page_buffer, PAGE_SIZE);
|
||||
MM.unquickmap_page();
|
||||
{
|
||||
SpinlockLocker mm_locker(s_mm_lock);
|
||||
u8* dest_ptr = MM.quickmap_page(*vmobject_physical_page_entry);
|
||||
memcpy(dest_ptr, page_buffer, PAGE_SIZE);
|
||||
MM.unquickmap_page();
|
||||
}
|
||||
|
||||
remap_vmobject_page(page_index_in_vmobject);
|
||||
return PageFaultResponse::Continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue