Page MenuHomeFreeBSD

Busy the map in vm_map_protect()
ClosedPublic

Authored by markj on Apr 10 2017, 4:38 PM.
Tags
None
Referenced Files
Unknown Object (File)
Nov 28 2023, 1:07 PM
Unknown Object (File)
Sep 26 2023, 10:27 AM
Unknown Object (File)
Jul 27 2023, 1:04 AM
Unknown Object (File)
Jul 8 2023, 6:19 PM
Unknown Object (File)
Jun 10 2023, 6:33 PM
Unknown Object (File)
May 16 2023, 10:35 PM
Unknown Object (File)
May 6 2023, 3:47 PM
Unknown Object (File)
Apr 22 2023, 6:24 PM
Subscribers

Details

Summary

Otherwise we are susceptible to a race with a concurrent vm_map_wire()
call, which faults pages into the object chain and drops the map lock
between each call to vm_fault(). In particular, vm_map_protect() will
only copy newly writable wired pages if MAP_ENTRY_USER_WIRED is set, but
vm_map_wire() only sets this flag after the fault loop. So we may end up
with a PROT_WRITE wired map entry whose top-level object does not
contain the entire range of pages.

It is also possible to address this race by checking for in-transition
map entries in the final loop of vm_map_protect(), but that is more
complicated since it requires some restart logic, and I don't see any
real benefits.

Unrelated changes are to add assertions to the map clip functions
(motivated by a bug in my first attempt to check for and handle
MAP_ENTRY_IN_TRANSITION entries in vm_map_protect()), and to
consistently use for-loops in vm_map_protect().

Test Plan

Peter tested the patch and reported the original problem ("vm_fault_copy_entry: main object missing page" during a fork).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj edited the test plan for this revision. (Show Details)
markj added reviewers: alc, kib.
markj added a subscriber: pho.
kib added inline comments.
sys/vm/vm_map.c
1658 ↗(On Diff #27311)

You might check more things there, e.g. assert that start belongs to the internal range of the entry.

This revision is now accepted and ready to land.Apr 10 2017, 6:52 PM
markj edited edge metadata.

Strengthen assertions.

This revision now requires review to proceed.Apr 10 2017, 7:34 PM
This revision is now accepted and ready to land.Apr 10 2017, 7:49 PM
This revision was automatically updated to reflect the committed changes.