Skip to content

Commit dd8a67f

Browse files
x-y-ztorvalds
authored andcommitted
mm/huge_memory.c: deposit page table when copying a PMD migration entry
We need to deposit pre-allocated PTE page table when a PMD migration entry is copied in copy_huge_pmd(). Otherwise, we will leak the pre-allocated page and cause a NULL pointer dereference later in zap_huge_pmd(). The missing counters during PMD migration entry copy process are added as well. The bug report is here: https://lkml.org/lkml/2017/10/29/214 Link: http://lkml.kernel.org/r/20171030144636.4836-1-zi.yan@sent.com Fixes: 84c3fc4 ("mm: thp: check pmd migration entry in common path") Signed-off-by: Zi Yan <zi.yan@cs.rutgers.edu> Reported-by: Fengguang Wu <fengguang.wu@intel.com> Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e08b187 commit dd8a67f

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

mm/huge_memory.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,9 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
941941
pmd = pmd_swp_mksoft_dirty(pmd);
942942
set_pmd_at(src_mm, addr, src_pmd, pmd);
943943
}
944+
add_mm_counter(dst_mm, MM_ANONPAGES, HPAGE_PMD_NR);
945+
atomic_long_inc(&dst_mm->nr_ptes);
946+
pgtable_trans_huge_deposit(dst_mm, dst_pmd, pgtable);
944947
set_pmd_at(dst_mm, addr, dst_pmd, pmd);
945948
ret = 0;
946949
goto out_unlock;

0 commit comments

Comments
 (0)