提交 e7a18d60 编写于 作者: J Jann Horn 提交者: Yongqiang Liu

mm: Fix TLB flush for not-first PFNMAP mappings in unmap_region()

stable inclusion
from stable-v4.19.259
commit 56fa5f3dd44a05a5eacd75ae9d00c5415046d371
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5UQH4
CVE: NA

--------------------------------

This is a stable-specific patch.
I botched the stable-specific rewrite of
commit b67fbebd ("mmu_gather: Force tlb-flush VM_PFNMAP vmas"):
As Hugh pointed out, unmap_region() actually operates on a list of VMAs,
and the variable "vma" merely points to the first VMA in that list.
So if we want to check whether any of the VMAs we're operating on is
PFNMAP or MIXEDMAP, we have to iterate through the list and check each VMA.
Signed-off-by: NJann Horn <jannh@google.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 7cbdfd4c
...@@ -2898,6 +2898,7 @@ static void unmap_region(struct mm_struct *mm, ...@@ -2898,6 +2898,7 @@ static void unmap_region(struct mm_struct *mm,
{ {
struct vm_area_struct *next = prev ? prev->vm_next : mm->mmap; struct vm_area_struct *next = prev ? prev->vm_next : mm->mmap;
struct mmu_gather tlb; struct mmu_gather tlb;
struct vm_area_struct *cur_vma;
lru_add_drain(); lru_add_drain();
tlb_gather_mmu(&tlb, mm, start, end); tlb_gather_mmu(&tlb, mm, start, end);
...@@ -2912,8 +2913,12 @@ static void unmap_region(struct mm_struct *mm, ...@@ -2912,8 +2913,12 @@ static void unmap_region(struct mm_struct *mm,
* concurrent flush in this region has to be coming through the rmap, * concurrent flush in this region has to be coming through the rmap,
* and we synchronize against that using the rmap lock. * and we synchronize against that using the rmap lock.
*/ */
if ((vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) != 0) for (cur_vma = vma; cur_vma; cur_vma = cur_vma->vm_next) {
tlb_flush_mmu(&tlb); if ((cur_vma->vm_flags & (VM_PFNMAP|VM_MIXEDMAP)) != 0) {
tlb_flush_mmu(&tlb);
break;
}
}
free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS, free_pgtables(&tlb, vma, prev ? prev->vm_end : FIRST_USER_ADDRESS,
next ? next->vm_start : USER_PGTABLES_CEILING); next ? next->vm_start : USER_PGTABLES_CEILING);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册