[ Sasha's backport helper bot ] Hi, Summary of potential issues: ⚠️ Found matching upstream commit but patch is missing proper reference to it Found matching upstream commit: c50f8e6053b0503375c2975bf47f182445aebb4c WARNING: Author mismatch between patch and found commit: Backport author: Suren Baghdasaryan<surenb@xxxxxxxxxx> Commit author: Barry Song<v-songbaohua@xxxxxxxx> Note: The patch differs from the upstream commit: --- 1: c50f8e6053b05 ! 1: 21842a7c36d00 mm: fix kernel BUG when userfaultfd_move encounters swapcache @@ Commit message Cc: Tangquan Zheng <zhengtangquan@xxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> + (cherry picked from commit c50f8e6053b0503375c2975bf47f182445aebb4c) + [surenb: resolved merged conflict caused by the difference in + move_swap_pte() arguments] + Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> ## mm/userfaultfd.c ## @@ @@ mm/userfaultfd.c: static int move_present_pte(struct mm_struct *mm, unsigned long dst_addr, unsigned long src_addr, pte_t *dst_pte, pte_t *src_pte, pte_t orig_dst_pte, pte_t orig_src_pte, - pmd_t *dst_pmd, pmd_t dst_pmdval, - spinlock_t *dst_ptl, spinlock_t *src_ptl) + spinlock_t *dst_ptl, spinlock_t *src_ptl, + struct folio *src_folio) @@ mm/userfaultfd.c: static int move_present_pte(struct mm_struct *mm, - double_pt_lock(dst_ptl, src_ptl); - if (!is_pte_pages_stable(dst_pte, src_pte, orig_dst_pte, orig_src_pte, + if (!pte_same(ptep_get(src_pte), orig_src_pte) || @@ mm/userfaultfd.c: static int move_swap_pte(struct mm_struct *mm, return -EAGAIN; } @@ mm/userfaultfd.c: static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd pte_t src_folio_pte; spinlock_t *src_ptl, *dst_ptl; @@ mm/userfaultfd.c: static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, - orig_dst_pte, orig_src_pte, dst_pmd, - dst_pmdval, dst_ptl, src_ptl, src_folio); + orig_dst_pte, orig_src_pte, + dst_ptl, src_ptl, src_folio); } else { + struct folio *folio = NULL; + @@ mm/userfaultfd.c: static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd goto out; } -- err = move_swap_pte(mm, dst_addr, src_addr, dst_pte, src_pte, -- orig_dst_pte, orig_src_pte, dst_pmd, -- dst_pmdval, dst_ptl, src_ptl); +- err = move_swap_pte(mm, dst_addr, src_addr, +- dst_pte, src_pte, +- orig_dst_pte, orig_src_pte, +- dst_ptl, src_ptl); + if (!pte_swp_exclusive(orig_src_pte)) { + err = -EBUSY; + goto out; @@ mm/userfaultfd.c: static int move_pages_pte(struct mm_struct *mm, pmd_t *dst_pmd + } + } + err = move_swap_pte(mm, dst_vma, dst_addr, src_addr, dst_pte, src_pte, -+ orig_dst_pte, orig_src_pte, dst_pmd, dst_pmdval, ++ orig_dst_pte, orig_src_pte, + dst_ptl, src_ptl, src_folio); } --- Results of testing on various branches: | Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.13.y | Success | Success |