git: vm: make normal MAP_FIXED replacement atomic

Aaron LI aly at crater.dragonflybsd.org
Fri Oct 23 06:19:04 PDT 2026


commit 4e138639de8840fc8ab2d6bac7d3520067f4d259
Author: David Bidner <david at crap.solutions>
Date:   Fri Oct 2 09:34:07 2026 +0200

    vm: make normal MAP_FIXED replacement atomic
    
    vm_mmap() removes an existing mapping before looking up the new object
    and inserting its mapping.  If the thread blocks in between, its LWKT
    tokens are released and another mmap() can claim the vacated range.
    The fixed mapping then fails with KERN_NO_SPACE.
    
    Add vm_map_replace() for normal MAP_FIXED mappings.  Wait for entries
    in transition before deleting any part of the range, then delete and
    insert under the same map lock.  Acquire the new object's shared token
    after deletion, since deleting an old mapping of the same object may
    require its token exclusively.
    
    Don't touch UKSMAP, virtual page table and internal stack mappings;
    they keep separate removal and insertion.
    
    Bug: https://bugs.dragonflybsd.org/issues/3442

Summary of changes:
 sys/vm/vm_map.c  | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 sys/vm/vm_map.h  |  2 ++
 sys/vm/vm_mmap.c | 27 +++++++++++++++++++--------
 3 files changed, 75 insertions(+), 8 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4e138639de8840fc8ab2d6bac7d3520067f4d259


-- 
DragonFly BSD source repository


More information about the Commits mailing list