Files
serenity/Kernel/Memory/AnonymousVMObject.cpp
Sönke Holz 15ada92d93 Kernel/MM: Handle concurrent page faults properly in handle_cow_fault()
Similar to the last commit, two page faults to the same page can happen
concurrently, so we need to be able to handle this properly.

Previously, we only held the VMObject's lock in
AnonymousVMObject::handle_cow_fault. But as explained in the previous
commit this isn't enough. We need to keep holding the lock until the
page is remapped.

Additionally, this commit makes handle_cow_fault() take a global lock
to make concurrent page faults to the same page from different processes
work correctly.
This global lock is unfortunately necessary since fork() clones all
VMObjects, so taking its lock won't prevent another process from
handling a page fault to the same physical pages. See the FIXME comment
for details.

There might be a better way to fix this, but this fix should still be
better than potentially panicking when concurrent COW faults occur.
2026-01-22 12:47:45 +01:00

15 KiB