Skip to content

Commit 16c54d6

Browse files
kirylgregkh
authored andcommitted
mm: fix apply_to_existing_page_range()
commit a995199384347261bb3f21b2e171fa7f988bd2f8 upstream. 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. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kirill A. Shutemov <[email protected]> Fixes: be1db47 ("mm/memory.c: add apply_to_existing_page_range() helper") Cc: Daniel Axtens <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Vlastimil Babka <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Kirill A. Shutemov <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent aed0aac commit 16c54d6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

mm/memory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2659,11 +2659,11 @@ static int apply_to_pte_range(struct mm_struct *mm, pmd_t *pmd,
26592659
if (fn) {
26602660
do {
26612661
if (create || !pte_none(*pte)) {
2662-
err = fn(pte++, addr, data);
2662+
err = fn(pte, addr, data);
26632663
if (err)
26642664
break;
26652665
}
2666-
} while (addr += PAGE_SIZE, addr != end);
2666+
} while (pte++, addr += PAGE_SIZE, addr != end);
26672667
}
26682668
*mask |= PGTBL_PTE_MODIFIED;
26692669

0 commit comments

Comments
 (0)