• David Hildenbrand's avatar
    mm: don't check VMA write permissions if the PTE/PMD indicates write permissions · f3ebdf04
    David Hildenbrand authored
    Staring at the comment "Recheck VMA as permissions can change since
    migration started" in remove_migration_pte() can result in confusion,
    because if the source PTE/PMD indicates write permissions, then there
    should be no need to check VMA write permissions when restoring migration
    entries or PTE-mapping a PMD.
    
    Commit d3cb8bf6 ("mm: migrate: Close race between migration completion
    and mprotect") introduced the maybe_mkwrite() handling in
    remove_migration_pte() in 2014, stating that a race between mprotect() and
    migration finishing would be possible, and that we could end up with a
    writable PTE that should be readable.
    
    However, mprotect() code first updates vma->vm_flags / vma->vm_page_prot
    and then walks the page tables to (a) set all present writable PTEs to
    read-only and (b) convert all writable migration entries to readable
    migration entries.  While walking the page tables and modifying the
    entries, migration code has...
    f3ebdf04
huge_memory.c 87.9 KB