On Thu, Jun 03, 2021 at 08:26:02PM -0700, Hugh Dickins wrote: > On Thu, 3 Jun 2021, Peter Xu wrote: > > > I found it by pure code review, that pte_same_as_swp() of unuse_vma() didn't > > Yes, that is an odd corner, easily missed. > > > 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. > > > > Cc: Hugh Dickins <hughd@xxxxxxxxxx> > > Cc: Andrea Arcangeli <aarcange@xxxxxxxxxx> > > Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> > > Signed-off-by: Peter Xu <peterx@xxxxxxxxxx> > > I expect you're right: swapoff used to hang forever (but interruptibly) > when this went wrong on powerpc originally. I don't know the uffd_wp > (nor the soft_dirty) end of it, but treating uffd_wp and soft_dirty > together looks a very good approach, so I'll venture an > > Acked-by: Hugh Dickins <hughd@xxxxxxxxxx> Thanks! > > But I think it should have a uffd_wp Fixes tag and be Cc stable. Yes, should be: Cc: stable@xxxxxxxxxxxxxxx # v5.7+ Fixes: f45ec5ff16a7 ("userfaultfd: wp: support swap and page migration") -- Peter Xu