git: kernel - Fix bug in vm_fault_page()

Matthew Dillon dillon at
Wed Nov 8 19:39:58 PST 2017

commit 7a45978d5d974a9a30aa324b77b57b76bfa76996
Author: Matthew Dillon <dillon at>
Date:   Wed Nov 8 19:35:14 2017 -0800

    kernel - Fix bug in vm_fault_page()
    * Fix a bug in vm_fault_page() and vm_fault_page_quick().  The code
      is not intended to update the user pmap, but if the vm_map_lookup()
      results in a COW, any existing page in the underlying pmap will no
      longer match the page that should be there.
      The user process will still work correctly in that it will fault the
      COW'd page if/when it tries to issue a write to that address, but
      userland will not have visibility to any kernel use of vm_fault_page()
      that modifies the page and causes a COW if the page has already been
      faulted in.
    * Fixed by detecting the COW and at least removing the pte from the pmap
      to force userland to re-fault it.
    * This fixes gdb operation on programs.  The problem did not rear its
      head before because the kernel did not pre-populate as many pages in the
      initial exec as it does now.
    * Enhance vm_map_lookup()'s &wired argument to return wflags instead,
      which includes FS_WIRED and also now has FS_DIDCOW.
    Reported-by: profmakx

Summary of changes:
 sys/kern/sys_process.c            | 10 ++---
 sys/platform/pc64/vmm/vmm_utils.c |  3 +-
 sys/platform/pc64/x86_64/pmap.c   | 14 +++----
 sys/vfs/procfs/procfs_mem.c       |  2 +-
 sys/vm/vm_fault.c                 | 80 +++++++++++++++++++++------------------
 sys/vm/vm_map.c                   |  9 +++--
 sys/vm/vm_map.h                   | 11 +++++-
 7 files changed, 74 insertions(+), 55 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list