git: kernel - Fix mlock() related panic and memory leak

Matthew Dillon dillon at
Sun Jul 12 21:12:44 PDT 2015

commit a51ba7a69d2c5084f2823fd37db008825d3f2d25
Author: Matthew Dillon <dillon at>
Date:   Sun Jul 12 21:07:55 2015 -0700

    kernel - Fix mlock() related panic and memory leak
    * If a process exits with mlock()d pages, the pages are left wired,
      causing an immediate memory leak and also leading to an assertion
      and panic later on when the kernel tries to free the pages.
    * The problem is due to an exit optimization which calls
      pmap_remove_pages() before deleting the mappings.  vm_fault_unwire()
      expects the pmap to have the pages and fails to properly adjust the
      wire count when it doesn't.
    * Fixed by testing pmap->pm_stats.wired_count and shifting the
      pmap_remove_pages() call to after the maps are removed if it is
    Reported-by: marino via muscles panic

Summary of changes:
 sys/vm/vm_map.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

DragonFly BSD source repository

More information about the Commits mailing list