summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnshuman Khandual <anshuman.khandual@arm.com>2021-01-05 16:54:11 +0530
committerWill Deacon <will@kernel.org>2021-01-20 12:27:57 +0000
commitedb739eed8f37e2846641313ff1308e872a30d98 (patch)
tree254d33c2726a48ce74b07e67c1c18aa97ae9fb5b
parent7001d4af926b26469a0604eca80dc73b80c5faa8 (diff)
downloadlinux-edb739eed8f37e2846641313ff1308e872a30d98.tar.gz
linux-edb739eed8f37e2846641313ff1308e872a30d98.tar.bz2
linux-edb739eed8f37e2846641313ff1308e872a30d98.zip
arm64/mm: Add warning for outside range requests in vmemmap_populate()
vmemmap_populate() does not validate the requested vmemmap address range to be inside the platform assigned space i.e [VMEMMAP_START..VMEMMAP_END] for vmemmap. Instead it would just go ahead and create the mapping which might then overlap with other sections in the kernel virtual address space. Just adding an warning here for range overrun which would help detect the problem earlier on, before a potential struct page corruption. This also makes vmemmap_populate() symmetrical with vmemmap_free() which already has a similar warning. Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> Cc: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> Link: https://lore.kernel.org/r/1609845851-25064-1-git-send-email-anshuman.khandual@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--arch/arm64/mm/mmu.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index ae0c3d023824..f938e8020523 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1094,6 +1094,7 @@ static void free_empty_tables(unsigned long addr, unsigned long end,
int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
struct vmem_altmap *altmap)
{
+ WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));
return vmemmap_populate_basepages(start, end, node, altmap);
}
#else /* !ARM64_SWAPPER_USES_SECTION_MAPS */
@@ -1107,6 +1108,7 @@ int __meminit vmemmap_populate(unsigned long start, unsigned long end, int node,
pud_t *pudp;
pmd_t *pmdp;
+ WARN_ON((start < VMEMMAP_START) || (end > VMEMMAP_END));
do {
next = pmd_addr_end(addr, end);