lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 24 Apr 2019 01:47:47 +0300 From: Serge Semin <fancer.lancer@...il.com> To: Ralf Baechle <ralf@...ux-mips.org>, Paul Burton <paul.burton@...s.com>, James Hogan <jhogan@...nel.org>, Matt Redfearn <matt.redfearn@...s.com>, Mike Rapoport <rppt@...ux.ibm.com>, Andrew Morton <akpm@...ux-foundation.org>, Michal Hocko <mhocko@...e.com>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, Thomas Bogendoerfer <tbogendoerfer@...e.de>, Huacai Chen <chenhc@...ote.com>, Stefan Agner <stefan@...er.ch>, Stephen Rothwell <sfr@...b.auug.org.au>, Alexandre Belloni <alexandre.belloni@...tlin.com>, Juergen Gross <jgross@...e.com> Cc: linux-mips@...r.kernel.org, linux-kernel@...r.kernel.org, Serge Semin <fancer.lancer@...il.com> Subject: [PATCH 11/12] mips: Make sure dt memory regions are valid There are situations when memory regions coming from dts may be too big for the platform physical address space. It especially concerns XPA-capable systems. Bootleader may determine more than 4GB memory available and pass it to the kernel over dts memory node, while kernel is built without XPA support. In this case the region may either simply be truncated by add_memory_region() method or by u64->phys_addr_t type casting. But in worst case the method can even drop the memory region if it exceedes PHYS_ADDR_MAX size. So lets make sure the retrieved from dts memory regions are valid, and if some of them isn't just manually truncate it with a warning printed out. Signed-off-by: Serge Semin <fancer.lancer@...il.com> --- arch/mips/kernel/prom.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/prom.c b/arch/mips/kernel/prom.c index 437a174e3ef9..28bf01961bb2 100644 --- a/arch/mips/kernel/prom.c +++ b/arch/mips/kernel/prom.c @@ -41,7 +41,19 @@ char *mips_get_machine_name(void) #ifdef CONFIG_USE_OF void __init early_init_dt_add_memory_arch(u64 base, u64 size) { - return add_memory_region(base, size, BOOT_MEM_RAM); + if (base >= PHYS_ADDR_MAX) { + pr_warn("Trying to add an invalid memory region, skipped\n"); + return; + } + + /* Truncate the passed memory region instead of type casting */ + if (base + size - 1 >= PHYS_ADDR_MAX || base + size < base) { + pr_warn("Truncate memory region %llx @ %llx to size %llx\n", + size, base, PHYS_ADDR_MAX - base); + size = PHYS_ADDR_MAX - base; + } + + add_memory_region(base, size, BOOT_MEM_RAM); } int __init early_init_dt_reserve_memory_arch(phys_addr_t base, -- 2.21.0
Powered by blists - more mailing lists