* FAILED: patch "[PATCH] userfaultfd: change src_folio after ensuring it's unpinned in" failed to apply to 6.8-stable tree
@ 2024-04-23 13:10 gregkh
2024-04-23 17:52 ` [PATCH 6.8.y] userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE Lokesh Gidra
0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2024-04-23 13:10 UTC (permalink / raw)
To: lokeshgidra, aarcange, akpm, david, kaleshsingh, ngeoffray,
peterx, stable, willy, zhengqi.arch
Cc: stable
The patch below does not apply to the 6.8-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.8.y
git checkout FETCH_HEAD
git cherry-pick -x c0205eaf3af9f5db14d4b5ee4abacf4a583c3c50
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2024042334-agenda-nutlike-cb77@gregkh' --subject-prefix 'PATCH 6.8.y' HEAD^..
Possible dependencies:
c0205eaf3af9 ("userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE")
eb1521dad8f3 ("userfaultfd: handle zeropage moves by UFFDIO_MOVE")
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c0205eaf3af9f5db14d4b5ee4abacf4a583c3c50 Mon Sep 17 00:00:00 2001
From: Lokesh Gidra <lokeshgidra@google.com>
Date: Thu, 4 Apr 2024 10:17:26 -0700
Subject: [PATCH] userfaultfd: change src_folio after ensuring it's unpinned in
UFFDIO_MOVE
Commit d7a08838ab74 ("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: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Acked-by: David 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: Andrew Morton <akpm@linux-foundation.org>
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9859aa4f7553..89f58c7603b2 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2259,9 +2259,6 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
goto unlock_ptls;
}
- folio_move_anon_rmap(src_folio, dst_vma);
- WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
-
src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
/* Folio got pinned from under us. Put it back and fail the move. */
if (folio_maybe_dma_pinned(src_folio)) {
@@ -2270,6 +2267,9 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
goto unlock_ptls;
}
+ folio_move_anon_rmap(src_folio, dst_vma);
+ WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
+
_dst_pmd = mk_huge_pmd(&src_folio->page, dst_vma->vm_page_prot);
/* Follow mremap() behavior and treat the entry dirty after the move */
_dst_pmd = pmd_mkwrite(pmd_mkdirty(_dst_pmd), dst_vma);
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 6.8.y] userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE
2024-04-23 13:10 FAILED: patch "[PATCH] userfaultfd: change src_folio after ensuring it's unpinned in" failed to apply to 6.8-stable tree gregkh
@ 2024-04-23 17:52 ` Lokesh Gidra
2024-04-23 18:00 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Lokesh Gidra @ 2024-04-23 17:52 UTC (permalink / raw)
To: stable
Cc: surenb, Lokesh Gidra, David Hildenbrand, Andrea Arcangeli,
Kalesh Singh, Nicolas Geoffray, Peter Xu, Qi Zheng,
Matthew Wilcox, Andrew Morton
Commit d7a08838ab74 ("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: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Acked-by: David 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: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit c0205eaf3af9f5db14d4b5ee4abacf4a583c3c50)
Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
---
mm/huge_memory.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 94c958f7ebb5..6790f93fda45 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2244,9 +2244,6 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
goto unlock_ptls;
}
- folio_move_anon_rmap(src_folio, dst_vma);
- WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
-
src_pmdval = pmdp_huge_clear_flush(src_vma, src_addr, src_pmd);
/* Folio got pinned from under us. Put it back and fail the move. */
if (folio_maybe_dma_pinned(src_folio)) {
@@ -2255,6 +2252,9 @@ int move_pages_huge_pmd(struct mm_struct *mm, pmd_t *dst_pmd, pmd_t *src_pmd, pm
goto unlock_ptls;
}
+ folio_move_anon_rmap(src_folio, dst_vma);
+ WRITE_ONCE(src_folio->index, linear_page_index(dst_vma, dst_addr));
+
_dst_pmd = mk_huge_pmd(&src_folio->page, dst_vma->vm_page_prot);
/* Follow mremap() behavior and treat the entry dirty after the move */
_dst_pmd = pmd_mkwrite(pmd_mkdirty(_dst_pmd), dst_vma);
--
2.44.0.769.g3c40516874-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.8.y] userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE
2024-04-23 17:52 ` [PATCH 6.8.y] userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE Lokesh Gidra
@ 2024-04-23 18:00 ` Greg KH
0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2024-04-23 18:00 UTC (permalink / raw)
To: Lokesh Gidra
Cc: stable, surenb, David Hildenbrand, Andrea Arcangeli,
Kalesh Singh, Nicolas Geoffray, Peter Xu, Qi Zheng,
Matthew Wilcox, Andrew Morton
On Tue, Apr 23, 2024 at 10:52:38AM -0700, Lokesh Gidra wrote:
> Commit d7a08838ab74 ("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: adef440691ba ("userfaultfd: UFFDIO_MOVE uABI")
> Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
> Acked-by: David 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: Andrew Morton <akpm@linux-foundation.org>
> (cherry picked from commit c0205eaf3af9f5db14d4b5ee4abacf4a583c3c50)
> Signed-off-by: Lokesh Gidra <lokeshgidra@google.com>
Now queued up, thanks.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-04-23 18:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23 13:10 FAILED: patch "[PATCH] userfaultfd: change src_folio after ensuring it's unpinned in" failed to apply to 6.8-stable tree gregkh
2024-04-23 17:52 ` [PATCH 6.8.y] userfaultfd: change src_folio after ensuring it's unpinned in UFFDIO_MOVE Lokesh Gidra
2024-04-23 18:00 ` Greg KH
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.