linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64/mm: Add warning for outside range requests in vmemmap_populate()
@ 2021-01-05 11:24 Anshuman Khandual
  2021-01-20 13:01 ` Will Deacon
  0 siblings, 1 reply; 2+ messages in thread
From: Anshuman Khandual @ 2021-01-05 11:24 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Anshuman Khandual, Catalin Marinas, Will Deacon, linux-kernel

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>
---
This applies on v5.11-rc2

 arch/arm64/mm/mmu.c | 2 ++
 1 file changed, 2 insertions(+)

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);
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] arm64/mm: Add warning for outside range requests in vmemmap_populate()
  2021-01-05 11:24 [PATCH] arm64/mm: Add warning for outside range requests in vmemmap_populate() Anshuman Khandual
@ 2021-01-20 13:01 ` Will Deacon
  0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2021-01-20 13:01 UTC (permalink / raw)
  To: Anshuman Khandual, linux-arm-kernel
  Cc: catalin.marinas, kernel-team, Will Deacon, linux-kernel

On Tue, 5 Jan 2021 16:54:11 +0530, Anshuman Khandual wrote:
> 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.

Applied to arm64 (for-next/misc), thanks!

[1/1] arm64/mm: Add warning for outside range requests in vmemmap_populate()
      https://git.kernel.org/arm64/c/edb739eed8f3

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-01-20 14:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-05 11:24 [PATCH] arm64/mm: Add warning for outside range requests in vmemmap_populate() Anshuman Khandual
2021-01-20 13:01 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).