kernel - Fix bug in vm_fault_page()
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 9 Nov 2017 03:35:14 +0000 (19:35 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 9 Nov 2017 03:35:14 +0000 (19:35 -0800)
commit7a45978d5d974a9a30aa324b77b57b76bfa76996
tree94a26a0db8cef6172b4cc6f68c0b2792e55df89a
parent63c41f054a1b30af58a2e6d6b92393b68aae2402
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
sys/kern/sys_process.c
sys/platform/pc64/vmm/vmm_utils.c
sys/platform/pc64/x86_64/pmap.c
sys/vfs/procfs/procfs_mem.c
sys/vm/vm_fault.c
sys/vm/vm_map.c
sys/vm/vm_map.h