Which is also where they are removed from the LRU.
The plot thickens...
Looks like we should move the anon_vma freeing from free_pgtables
over to remove_vma?
This code is just below the tlb_finish_mmu in exit_mmap:
/*
* Walk the list again, actually closing and freeing it,
* with preemption enabled, without holding any MM locks.
*/
while (vma)
vma = remove_vma(vma);
This comment in free_pgtables is a little suspect:
/*
* Hide vma from rmap and truncate_pagecache before freeing
* pgtables
*/
unlink_anon_vmas(vma);
unlink_file_vma(vma);
After all, the rmap code will quickly notice that there either are
no page tables, or the page tables no longer have anything in them.
It looks like we may have had this use-after-free bug in the VM for
quite a while... I am not entirely sure what exposed the bug, but
I can see how it works.
--