Message ID | DB7PR02MB3979BC324920A783BD5BB721BB5A0@DB7PR02MB3979.eurprd02.prod.outlook.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [RFC,v1,1/4] mm/remote_mapping: mirror a process address space | expand |
On Wed, Dec 11, 2019 at 09:29:20AM +0000, Mircea CIRJALIU - MELIU wrote:
> When calling zap_vma_ptes() on VM_PFNMAP VMAs involving huge mappings,
Do we have such VMAs?
> On Wed, Dec 11, 2019 at 09:29:20AM +0000, Mircea CIRJALIU - MELIU wrote: > > When calling zap_vma_ptes() on VM_PFNMAP VMAs involving huge > mappings, > > Do we have such VMAs? I have such VMAs in the remote mapping feature. Any reason why these VMAs are dangerous? > > -- > Kirill A. Shutemov > > ________________________ > This email was scanned by Bitdefender
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 41a0fbd..92ce487 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1804,7 +1804,11 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, int flush_needed = 1; if (pmd_present(orig_pmd)) { - page = pmd_page(orig_pmd); + page = vm_normal_page_pmd(vma, addr, orig_pmd); + if (unlikely(!page)) { + spin_unlock(ptl); + return 1; + } page_remove_rmap(page, true); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page);
When calling zap_vma_ptes() on VM_PFNMAP VMAs involving huge mappings, pmd_page() will return an invalid page, causing trouble. Use instead vm_normal_page_pmd() and test for returned page like zap_pte_range(). Signed-off-by: Mircea Cirjaliu <mcirjaliu@bitdefender.com> --- mm/huge_memory.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)