HomeFreeBSD

vm_fault: Fix vm_fault_populate()'s handling of VM_FAULT_WIRE

Description

vm_fault: Fix vm_fault_populate()'s handling of VM_FAULT_WIRE

vm_map_wire() works by calling vm_fault(VM_FAULT_WIRE) on each page in
the rage. (For largepage mappings, it calls vm_fault() once per large
page.)

A pager's populate method may return more than one page to be mapped.
If VM_FAULT_WIRE is also specified, we'd wire each page in the run, not
just the fault page. Consider an object with two pages mapped in a
vm_map_entry, and suppose vm_map_wire() is called on the entry. Then,
the first vm_fault() would allocate and wire both pages, and the second
would encounter a valid page upon lookup and wire it again in the
regular fault handler. So the second page is wired twice and will be
leaked when the object is destroyed.

Fix the problem by modify vm_fault_populate() to wire only the fault
page. Also modify the error handler for pmap_enter(psind=1) to not test
fs->wired, since it must be false.

PR: 260347
Reviewed by: alc, kib
Sponsored by: The FreeBSD Foundation

(cherry picked from commit 88642d978a999aaa3752e86d2f54b1a6aba7fc85)

Details

Provenance
markjAuthored on Dec 14 2021, 8:10 PM
Parents
rGfa4e4d55b3c8: Clean up a couple of MD warts in vm_fault_populate():
Branches
Unknown
Tags
Unknown