Skip to content

Commit

Permalink
Revert "mm: always flush VMA ranges affected by zap_page_range"
Browse files Browse the repository at this point in the history
There was a bug in Linux that could cause madvise (and mprotect?) system
calls to return to userspace without the TLB having been flushed for all
the pages involved.

This could happen when multiple threads of a process made simultaneous
madvise and/or mprotect calls.

This was noticed in the summer of 2017, at which time two solutions
were created:

  56236a5 ("mm: refactor TLB gathering API")
  99baac2 ("mm: fix MADV_[FREE|DONTNEED] TLB flush miss problem")
and
  4647706 ("mm: always flush VMA ranges affected by zap_page_range")

We need only one of these solutions, and the former appears to be a
little more efficient than the latter, so revert that one.

This reverts 4647706 ("mm: always flush VMA ranges affected by
zap_page_range")

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Rik van Riel <[email protected]>
Acked-by: Mel Gorman <[email protected]>
Cc: Andy Lutomirski <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Mel Gorman <[email protected]>
Cc: "Aneesh Kumar K.V" <[email protected]>
Cc: Nicholas Piggin <[email protected]>
Cc: Nadav Amit <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
rikvanriel authored and torvalds committed Aug 17, 2018
1 parent c98aff6 commit 50c150f
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions mm/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,20 +1613,8 @@ void zap_page_range(struct vm_area_struct *vma, unsigned long start,
tlb_gather_mmu(&tlb, mm, start, end);
update_hiwater_rss(mm);
mmu_notifier_invalidate_range_start(mm, start, end);
for ( ; vma && vma->vm_start < end; vma = vma->vm_next) {
for ( ; vma && vma->vm_start < end; vma = vma->vm_next)
unmap_single_vma(&tlb, vma, start, end, NULL);

/*
* zap_page_range does not specify whether mmap_sem should be
* held for read or write. That allows parallel zap_page_range
* operations to unmap a PTE and defer a flush meaning that
* this call observes pte_none and fails to flush the TLB.
* Rather than adding a complex API, ensure that no stale
* TLB entries exist when this call returns.
*/
flush_tlb_range(vma, start, end);
}

mmu_notifier_invalidate_range_end(mm, start, end);
tlb_finish_mmu(&tlb, start, end);
}
Expand Down

0 comments on commit 50c150f

Please sign in to comment.