mm/swap: fix pte_same_as_swp() not removing uffd-wp bit when compare
authorPeter Xu <peterx@redhat.com>
Wed, 16 Jun 2021 01:23:16 +0000 (18:23 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 23 Jun 2021 12:42:53 +0000 (14:42 +0200)
commit12eb3c2c1a4f6e7c30de2aa0a09cb1b9e19fa9c0
treeebc314dd3c679fb3cf95fe566b8c330b1e1c7d85
parentfc7fdd8c5c2ad2fe3e297698be9d4dbe4a4e0579
mm/swap: fix pte_same_as_swp() not removing uffd-wp bit when compare

commit 099dd6878b9b12d6bbfa6bf29ce0c8ddd38f6901 upstream.

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: https://lkml.kernel.org/r/20210603180546.9083-1-peterx@redhat.com
Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration")
Signed-off-by: Peter Xu <peterx@redhat.com>
Acked-by: Hugh Dickins <hughd@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: <stable@vger.kernel.org> [5.7+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/linux/swapops.h
mm/swapfile.c