path: root/mm
diff options
authorPeter Xu <>2021-06-15 18:23:16 -0700
committerLinus Torvalds <>2021-06-16 09:24:42 -0700
commit099dd6878b9b12d6bbfa6bf29ce0c8ddd38f6901 (patch)
treeb6088a641393719d3fd835cd9a0c346ba7c54b30 /mm
parent25182f05ffed0b45602438693e4eed5d7f3ebadd (diff)
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. Link: 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 <>
Diffstat (limited to 'mm')
1 files changed, 1 insertions, 1 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 149e77454e3c..996afa8131c8 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -1900,7 +1900,7 @@ unsigned int count_swap_pages(int type, int free)
static inline int pte_same_as_swp(pte_t pte, pte_t swp_pte)
- return pte_same(pte_swp_clear_soft_dirty(pte), swp_pte);
+ return pte_same(pte_swp_clear_flags(pte), swp_pte);