mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 10:58:48 +09:00
FROMLIST: mm: protect SPF handler against anon_vma changes
The speculative page fault handler must be protected against anon_vma changes. This is because page_add_new_anon_rmap() is called during the speculative path. In addition, don't try speculative page fault if the VMA don't have an anon_vma structure allocated because its allocation should be protected by the mmap_sem. In __vma_adjust() when importer->anon_vma is set, there is no need to protect against speculative page faults since speculative page fault is aborted if the vma->anon_vma is not set. When calling page_add_new_anon_rmap() vma->anon_vma is necessarily valid since we checked for it when locking the pte and the anon_vma is removed once the pte is unlocked. So even if the speculative page fault handler is running concurrently with do_unmap(), as the pte is locked in unmap_region() - through unmap_vmas() - and the anon_vma unlinked later, because we check for the vma sequence counter which is updated in unmap_page_range() before locking the pte, and then in free_pgtables() so when locking the pte the change will be detected. Change-Id: I6c1f3b5c811d1ddd7b3f769082e8bbd40f5b52a0 Signed-off-by: Laurent Dufour <ldufour@linux.vnet.ibm.com> Link: https://lore.kernel.org/lkml/1523975611-15978-12-git-send-email-ldufour@linux.vnet.ibm.com/ Bug: 161210518 Signed-off-by: Vinayak Menon <vinmenon@codeaurora.org>
This commit is contained in:
committed by
Suren Baghdasaryan
parent
0525756e6b
commit
73ab9e34ff
@@ -412,7 +412,9 @@ void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *vma,
|
||||
* Hide vma from rmap and truncate_pagecache before freeing
|
||||
* pgtables
|
||||
*/
|
||||
vm_write_begin(vma);
|
||||
unlink_anon_vmas(vma);
|
||||
vm_write_end(vma);
|
||||
unlink_file_vma(vma);
|
||||
|
||||
if (is_vm_hugetlb_page(vma)) {
|
||||
@@ -426,7 +428,9 @@ void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *vma,
|
||||
&& !is_vm_hugetlb_page(next)) {
|
||||
vma = next;
|
||||
next = vma->vm_next;
|
||||
vm_write_begin(vma);
|
||||
unlink_anon_vmas(vma);
|
||||
vm_write_end(vma);
|
||||
unlink_file_vma(vma);
|
||||
}
|
||||
free_pgd_range(tlb, addr, vma->vm_end,
|
||||
|
||||
Reference in New Issue
Block a user