Commit 7d833ec2 authored by Lokesh Gidra's avatar Lokesh Gidra Committed by Omkar Sai Sandeep Katadi
Browse files

BACKPORT: userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE

Commit d7a08838 ("mm: userfaultfd: fix unexpected change to src_folio
when UFFDIO_MOVE fails") moved the src_folio->{mapping, index} changing to
after clearing the page-table and ensuring that it's not pinned.  This
avoids failure of swapout+migration and possibly memory corruption.

However, the commit missed fixing it in the huge-page case.

Link: https://lkml.kernel.org/r/20240404171726.2302435-1-lokeshgidra@google.com


Fixes: adef4406 ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: default avatarLokesh Gidra <lokeshgidra@google.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: Nicolas Geoffray <ngeoffray@google.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Qi Zheng <zhengqi.arch@bytedance.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>

(cherry picked from commit c0205eaf)
Conflicts:
	mm/huge_memory.c

1. Replace folio_move_anon_rmap() with page_move_anon_rmap().

Bug: 274911254
Bug: 339845931
Signed-off-by: default avatarLokesh Gidra <lokeshgidra@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:4f658d77230e4d34734632f41af8267f93547dbb)
Merged-In: I15a07ea22de7ae38ed20320a73c995c7c48ef42b
Change-Id: I15a07ea22de7ae38ed20320a73c995c7c48ef42b
parent 39d282d5
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment