Skip to content

Commit 605f53f

Browse files
Ryan Robertsgregkh
Ryan Roberts
authored andcommitted
mm: don't skip arch_sync_kernel_mappings() in error paths
commit 3685024 upstream. Fix callers that previously skipped calling arch_sync_kernel_mappings() if an error occurred during a pgtable update. The call is still required to sync any pgtable updates that may have occurred prior to hitting the error condition. These are theoretical bugs discovered during code review. Link: https://lkml.kernel.org/r/[email protected] Fixes: 2ba3e69 ("mm/vmalloc: track which page-table levels were modified") Fixes: 0c95cba ("mm: apply_to_pte_range warn and fail if a large pte is encountered") Signed-off-by: Ryan Roberts <[email protected]> Reviewed-by: Anshuman Khandual <[email protected]> Reviewed-by: Catalin Marinas <[email protected]> Cc: Christop Hellwig <[email protected]> Cc: "Uladzislau Rezki (Sony)" <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 608cc7d commit 605f53f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

mm/memory.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,8 +2957,10 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
29572957
next = pgd_addr_end(addr, end);
29582958
if (pgd_none(*pgd) && !create)
29592959
continue;
2960-
if (WARN_ON_ONCE(pgd_leaf(*pgd)))
2961-
return -EINVAL;
2960+
if (WARN_ON_ONCE(pgd_leaf(*pgd))) {
2961+
err = -EINVAL;
2962+
break;
2963+
}
29622964
if (!pgd_none(*pgd) && WARN_ON_ONCE(pgd_bad(*pgd))) {
29632965
if (!create)
29642966
continue;

mm/vmalloc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,13 @@ static int vmap_small_pages_range_noflush(unsigned long addr, unsigned long end,
586586
mask |= PGTBL_PGD_MODIFIED;
587587
err = vmap_pages_p4d_range(pgd, addr, next, prot, pages, &nr, &mask);
588588
if (err)
589-
return err;
589+
break;
590590
} while (pgd++, addr = next, addr != end);
591591

592592
if (mask & ARCH_PAGE_TABLE_SYNC_MASK)
593593
arch_sync_kernel_mappings(start, end);
594594

595-
return 0;
595+
return err;
596596
}
597597

598598
/*

0 commit comments

Comments
 (0)