James Houghton b30c14cd61 hugetlb: unshare some PMDs when splitting VMAs
PMD sharing can only be done in PUD_SIZE-aligned pieces of VMAs; however,
it is possible that HugeTLB VMAs are split without unsharing the PMDs
first.

Without this fix, it is possible to hit the uffd-wp-related WARN_ON_ONCE
in hugetlb_change_protection [1].  The key there is that
hugetlb_unshare_all_pmds will not attempt to unshare PMDs in
non-PUD_SIZE-aligned sections of the VMA.

It might seem ideal to unshare in hugetlb_vm_op_open, but we need to
unshare in both the new and old VMAs, so unsharing in hugetlb_vm_op_split
seems natural.

[1]: https://lore.kernel.org/linux-mm/CADrL8HVeOkj0QH5VZZbRzybNE8CG-tEGFshnA+bG9nMgcWtBSg@mail.gmail.com/

Link: https://lkml.kernel.org/r/20230104231910.1464197-1-jthoughton@google.com
Fixes: 6dfeaff93be1 ("hugetlb/userfaultfd: unshare all pmds for hugetlbfs when register wp")
Signed-off-by: James Houghton <jthoughton@google.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Acked-by: Peter Xu <peterx@redhat.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2023-01-11 16:14:20 -08:00
..
2022-12-14 12:20:00 -08:00
2022-12-14 12:20:00 -08:00
2022-12-21 14:31:52 -08:00
2021-05-05 11:27:24 -07:00
2022-12-17 14:06:53 -06:00
2022-12-15 11:12:21 -08:00
2022-09-26 19:46:16 -07:00
2022-12-17 14:06:53 -06:00
2022-11-27 23:38:02 +01:00
2022-12-13 19:29:45 -08:00
2022-12-11 18:12:08 -08:00
2022-12-13 19:29:45 -08:00
2022-10-03 14:02:43 -07:00
2022-09-26 19:46:09 -07:00
2022-12-17 14:06:53 -06:00
2022-09-26 19:46:26 -07:00
2021-05-07 00:26:35 -07:00
2022-12-14 12:20:00 -08:00
2022-12-13 19:29:45 -08:00
2022-12-13 19:29:45 -08:00
2022-12-17 14:06:53 -06:00
2022-12-17 14:06:53 -06:00
2022-12-11 18:12:10 -08:00
2022-12-11 18:12:10 -08:00
2022-12-11 18:12:10 -08:00