mm/hugetlb: avoid corrupting page->mapping in hugetlb_mcopy_atomic_pte
authorMiaohe Lin <linmiaohe@huawei.com>
Tue, 12 Jul 2022 13:05:42 +0000 (21:05 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 5 Sep 2022 08:30:04 +0000 (10:30 +0200)
commitda60ddd80d09f8371fbba1a238a4b318d13ba698
tree6fddc7b21c91cdc96889d29c4947a46bef2a2928
parente7a792dcd6a7e51d4406bacd46a6c7cfcc78f2f2
mm/hugetlb: avoid corrupting page->mapping in hugetlb_mcopy_atomic_pte

commit ab74ef708dc51df7cf2b8a890b9c6990fac5c0c6 upstream.

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: f619147104c8 ("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>
Signed-off-by: Axel Rasmussen <axelrasmussen@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/hugetlb.c