• Mel Gorman's avatar
    mm, mprotect: flush TLB if potentially racing with a parallel reclaim leaving stale TLB entries · f1181047
    Mel Gorman authored
    commit 3ea27719 upstream.
    
    Stable note for 4.4: The upstream patch patches madvise(MADV_FREE) but 4.4
    	does not have support for that feature. The changelog is left
    	as-is but the hunk related to madvise is omitted from the backport.
    
    Nadav Amit identified a theoritical race between page reclaim and
    mprotect due to TLB flushes being batched outside of the PTL being held.
    
    He described the race as follows:
    
            CPU0                            CPU1
            ----                            ----
                                            user accesses memory using RW PTE
                                            [PTE now cached in TLB]
            try_to_unmap_one()
            ==> ptep_get_and_clear()
            ==> set_tlb_ubc_flush_pending()
                                            mprotect(addr, PROT_READ)
                                            ==> change_pte_range()
                             ...
    f1181047
mprotect.c 10.9 KB