Commit 989fc66b authored by Suren Baghdasaryan's avatar Suren Baghdasaryan Committed by Lokesh Gidra
Browse files

BACKPORT: userfaultfd: fix a crash in UFFDIO_MOVE when PMD is a migration entry

When UFFDIO_MOVE encounters a migration PMD entry, it proceeds with
obtaining a folio and accessing it even though the entry is swp_entry_t.
Add the missing check and let split_huge_pmd() handle migration entries.
While at it also remove unnecessary folio check.

[surenb@google.com: remove extra folio check, per David]
  Link: https://lkml.kernel.org/r/20250807200418.1963585-1-surenb@google.com
Link: https://lkml.kernel.org/r/20250806220022.926763-1-surenb@google.com


Fixes: adef4406 ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: default avatarSuren Baghdasaryan <surenb@google.com>
Reported-by: default avatar <syzbot+b446dbe27035ef6bd6c2@syzkaller.appspotmail.com>
Closes: https://lore.kernel.org/all/68794b5c.a70a0220.693ce.0050.GAE@google.com/


Reviewed-by: default avatarPeter Xu <peterx@redhat.com>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Lokesh Gidra <lokeshgidra@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
(cherry picked from commit aba6faec)

Conflicts:
1. Replaced pmd_folio() with pfn_folio(pmd_pfn()) as it was defined in
   later kernel version.
2. Replaced is_huge_zero_folio() with is_huge_zero_page() as it was
   defined in later kernel version.

Signed-off-by: default avatarLokesh Gidra <lokeshgidra@google.com>
Bug: 434648751
Cherrypick-From: https://android-review.googlesource.com/q/commit:fa168980b0b2590a53b522f829470622b8ae16ad
Merged-In: I3c94a615224e4a9b956998be7cc5bae58011ac16
Change-Id: I3c94a615224e4a9b956998be7cc5bae58011ac16
Bug: 446709123
parent 1d408bd6
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment