FAILED: patch "[PATCH] mm: fix apply_to_existing_page_range()" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-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 <[email protected]>.
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.1.y
git checkout FETCH_HEAD
git cherry-pick -x a995199384347261bb3f21b2e171fa7f988bd2f8
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025042114-author-badness-6b2c@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a995199384347261bb3f21b2e171fa7f988bd2f8 Mon Sep 17 00:00:00 2001
From: "Kirill A. Shutemov" <[email protected]>
Date: Wed, 9 Apr 2025 12:40:43 +0300
Subject: [PATCH] mm: fix apply_to_existing_page_range()
In the case of apply_to_existing_page_range(), apply_to_pte_range() is reached with 'create' set to false. When !create, the loop over the PTE page table is broken.
apply_to_pte_range() will only move to the next PTE entry if 'create' is true or if the current entry is not pte_none().
This means that the user of apply_to_existing_page_range() will not have 'fn' called for any entries after the first pte_none() in the PTE page table.
Fix the loop logic in apply_to_pte_range().
There are no known runtime issues from this, but the fix is trivial enough for stable@ even without a known buggy user.
mm/memory.c +2 -2
@@ -2938,11 +2938,11 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,if (fn) {do {if (create || !pte_none (ptep_get (pte))) { - err =fn (pte++, addr, data); + err =fn (pte, addr, data);if (err)break ; } - }while (addr +=PAGE_SIZE , addr != end); + }while (pte++, addr +=PAGE_SIZE , addr != end); } *mask |=PGTBL_PTE_MODIFIED ;
PATCH 1/1 mm: fix apply_to_existing_page_range()
In the case of apply_to_existing_page_range(), apply_to_pte_range() is reached with 'create' set to false. When !create, the loop over the PTE page table is broken.
apply_to_pte_range() will only move to the next PTE entry if 'create' is true or if the current entry is not pte_none().
This means that the user of apply_to_existing_page_range() will not have 'fn' called for any entries after the first pte_none() in the PTE page table.
Fix the loop logic in apply_to_pte_range().
There are no known runtime issues from this, but the fix is trivial enough for stable@ even without a known buggy user.
--- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory.c +2 -2
@@ -2659,11 +2659,11 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,if (fn) {do {if (create || !pte_none (*pte)) { - err =fn (pte++, addr, data); + err =fn (pte, addr, data);if (err)break ; } - }while (addr +=PAGE_SIZE , addr != end); + }while (pte++, addr +=PAGE_SIZE , addr != end); } *mask |=PGTBL_PTE_MODIFIED ;
Signature · 1 line
2.47.2
Sasha Levin
maintainerRe: [PATCH 6.1.y] mm: fix apply_to_existing_page_range()
[ 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: a995199384347261bb3f21b2e171fa7f988bd2f8
Status in newer kernel trees:
6.14.y | Not found
6.12.y | Not found
6.6.y | Not found
Note: The patch differs from the upstream commit:
---
1: a995199384347 ! 1: 003668f907d5a mm: fix apply_to_existing_page_range()
@@ Commit message
+ (cherry picked from commit a995199384347261bb3f21b2e171fa7f988bd2f8)
+ Signed-off-by: Kirill A. Shutemov <[email protected]>
## mm/memory.c ##
@@ mm/memory.c: static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
if (fn) {
do {
- if (create || !pte_none(ptep_get(pte))) {
+ if (create || !pte_none(*pte)) {
- err = fn(pte++, addr, data);
+ err = fn(pte, addr, data);
if (err)
---
Results of testing on various branches:
| Branch | Patch Apply | Build Test | |---------------------------|-------------|------------| | stable/linux-6.1.y | Success | Success |