Commit bd9a23a
hugetlb: unshare some PMDs when splitting VMAs
[ Upstream commit b30c14c ]
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: 6dfeaff ("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>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 393d9e3 commit bd9a23a
1 file changed
+35
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
85 | 87 | | |
86 | 88 | | |
87 | 89 | | |
| |||
4164 | 4166 | | |
4165 | 4167 | | |
4166 | 4168 | | |
| 4169 | + | |
| 4170 | + | |
| 4171 | + | |
| 4172 | + | |
| 4173 | + | |
| 4174 | + | |
| 4175 | + | |
| 4176 | + | |
| 4177 | + | |
| 4178 | + | |
| 4179 | + | |
| 4180 | + | |
| 4181 | + | |
| 4182 | + | |
| 4183 | + | |
| 4184 | + | |
| 4185 | + | |
| 4186 | + | |
| 4187 | + | |
4167 | 4188 | | |
4168 | 4189 | | |
4169 | 4190 | | |
| |||
6349 | 6370 | | |
6350 | 6371 | | |
6351 | 6372 | | |
6352 | | - | |
6353 | | - | |
6354 | | - | |
6355 | | - | |
6356 | | - | |
| 6373 | + | |
| 6374 | + | |
| 6375 | + | |
6357 | 6376 | | |
6358 | 6377 | | |
6359 | 6378 | | |
6360 | 6379 | | |
6361 | 6380 | | |
6362 | | - | |
| 6381 | + | |
6363 | 6382 | | |
6364 | 6383 | | |
6365 | 6384 | | |
6366 | 6385 | | |
6367 | 6386 | | |
6368 | 6387 | | |
6369 | | - | |
6370 | | - | |
6371 | | - | |
6372 | 6388 | | |
6373 | 6389 | | |
6374 | 6390 | | |
| |||
6400 | 6416 | | |
6401 | 6417 | | |
6402 | 6418 | | |
| 6419 | + | |
| 6420 | + | |
| 6421 | + | |
| 6422 | + | |
| 6423 | + | |
| 6424 | + | |
| 6425 | + | |
| 6426 | + | |
| 6427 | + | |
| 6428 | + | |
6403 | 6429 | | |
6404 | 6430 | | |
6405 | 6431 | | |
| |||
0 commit comments