Skip to content

Commit ab74ef7

Browse files
MiaoheLinakpm00
authored andcommitted
mm/hugetlb: avoid corrupting page->mapping in hugetlb_mcopy_atomic_pte
In MCOPY_ATOMIC_CONTINUE case with a non-shared VMA, pages in the page cache are installed in the ptes. But hugepage_add_new_anon_rmap is called for them mistakenly because they're not vm_shared. This will corrupt the page->mapping used by page cache code. Link: https://lkml.kernel.org/r/20220712130542.18836-1-linmiaohe@huawei.com Fixes: f619147 ("userfaultfd: add UFFDIO_CONTINUE ioctl") Signed-off-by: Miaohe Lin <linmiaohe@huawei.com> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com> Cc: Axel Rasmussen <axelrasmussen@google.com> Cc: Peter Xu <peterx@redhat.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent ec66244 commit ab74ef7

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

mm/hugetlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6041,7 +6041,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
60416041
if (!huge_pte_none_mostly(huge_ptep_get(dst_pte)))
60426042
goto out_release_unlock;
60436043

6044-
if (vm_shared) {
6044+
if (page_in_pagecache) {
60456045
page_dup_file_rmap(page, true);
60466046
} else {
60476047
ClearHPageRestoreReserve(page);

0 commit comments

Comments
 (0)