mm/swap: fix pte_same_as_swp() not removing uffd-wp bit when compare

I found it by pure code review, that pte_same_as_swp() of unuse_vma()
didn't take uffd-wp bit into account when comparing ptes.
pte_same_as_swp() returning false negative could cause failure to
swapoff swap ptes that was wr-protected by userfaultfd.

Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration")
Signed-off-by: Peter Xu <>
Acked-by: Hugh Dickins <>
Cc: Andrea Arcangeli <>
Cc: <>	[5.7+]
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>
2 files changed