Kernel: Don't CoW non-writable pages

A page fault in a page marked for CoW should not trigger a CoW if the
page is non-writable. I think this makes sense.
This commit is contained in:
Andreas Kling 2019-12-02 19:20:09 +01:00
parent f41ae755ec
commit 05c65fb4f1
Notes: sideshowbarker 2024-07-19 10:58:51 +09:00

View file

@ -284,7 +284,7 @@ PageFaultResponse Region::handle_fault(const PageFault& fault)
return handle_zero_fault(page_index_in_region);
}
ASSERT(fault.type() == PageFault::Type::ProtectionViolation);
if (fault.access() == PageFault::Access::Write && should_cow(page_index_in_region)) {
if (fault.access() == PageFault::Access::Write && is_writable() && should_cow(page_index_in_region)) {
#ifdef PAGE_FAULT_DEBUG
dbgprintf("PV(cow) fault in Region{%p}[%u]\n", this, page_index_in_region);
#endif