Commit f45ec5ff16a75 ("userfaultfd: wp: support swap and page migration") introduced support for tracking the uffd wp bit during page migration. However the non-swap PTE variant was used to set the flag for zone device private pages which are a type of swap page. This leads to corruption of the swap offset if the original PTE has the uffd_wp flag set.
Unified · Split
| @@ -251,7 +251,7 @@ static bool remove_migration_pte(struct page *page, struct vm_area_struct *vma, · 250 unmodified lines | ||
| 251 | 251 | entry = make_device_private_entry(new, pte_write(pte)); |
| 252 | 252 | pte = swp_entry_to_pte(entry); |
| 253 | 253 | if (pte_swp_uffd_wp(*pvmw.pte)) |
| 254 | − pte = pte_mkuffd_wp(pte); | |
| 254 | + pte = pte_swp_mkuffd_wp(pte); | |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | |