Skip to content

Commit 3685024

Browse files
Ryan Robertsakpm00
authored andcommitted
mm: don't skip arch_sync_kernel_mappings() in error paths
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/20250226121610.2401743-1-ryan.roberts@arm.com 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 <ryan.roberts@arm.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Cc: Christop Hellwig <hch@infradead.org> Cc: "Uladzislau Rezki (Sony)" <urezki@gmail.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent adae46a commit 3685024

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
@@ -3051,8 +3051,10 @@ static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr,
30513051
next = pgd_addr_end(addr, end);
30523052
if (pgd_none(*pgd) && !create)
30533053
continue;
3054-
if (WARN_ON_ONCE(pgd_leaf(*pgd)))
3055-
return -EINVAL;
3054+
if (WARN_ON_ONCE(pgd_leaf(*pgd))) {
3055+
err = -EINVAL;
3056+
break;
3057+
}
30563058
if (!pgd_none(*pgd) && WARN_ON_ONCE(pgd_bad(*pgd))) {
30573059
if (!create)
30583060
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)