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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240722035701.696874-4-ruanjinjie@huawei.com>
Date: Mon, 22 Jul 2024 11:57:01 +0800
From: Jinjie Ruan <ruanjinjie@...wei.com>
To: <linux@...linux.org.uk>, <paul.walmsley@...ive.com>, <palmer@...belt.com>,
	<aou@...s.berkeley.edu>, <tglx@...utronix.de>, <mingo@...hat.com>,
	<bp@...en8.de>, <dave.hansen@...ux.intel.com>, <hpa@...or.com>,
	<arnd@...db.de>, <gregkh@...uxfoundation.org>, <deller@....de>,
	<javierm@...hat.com>, <bhe@...hat.com>, <robh@...nel.org>,
	<alexghiti@...osinc.com>, <bjorn@...osinc.com>, <akpm@...ux-foundation.org>,
	<namcao@...utronix.de>, <dawei.li@...ngroup.cn>, <chenjiahao16@...wei.com>,
	<rppt@...nel.org>, <julian.stecklina@...erus-technology.de>,
	<rafael.j.wysocki@...el.com>, <linux-arm-kernel@...ts.infradead.org>,
	<linux-riscv@...ts.infradead.org>, <linux-kernel@...r.kernel.org>
CC: <ruanjinjie@...wei.com>
Subject: [PATCH v4 3/3] riscv: kdump: Fix crash memory reserve exceed system memory bug

Similar with x86_32, on Riscv32 Qemu "virt" machine with 1GB memory, the
crash kernel "crashkernel=4G" is ok as below:
	crashkernel reserved: 0x00000000bf400000 - 0x00000001bf400000 (4096 MB)

The cause is that the crash_size is parsed and printed with "unsigned long
long" data type which is 8 bytes but allocated used with "phys_addr_t"
which is 4 bytes in memblock_phys_alloc_range().

Fix it by checking if the crash_size is greater than system RAM size and
warn out as parse_crashkernel_mem() do it if so.

After this patch, it fails and there is no above confusing reserve
success info.

Signed-off-by: Jinjie Ruan <ruanjinjie@...wei.com>
---
 arch/riscv/mm/init.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index bfa2dea95354..5d66a4937fcd 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1381,6 +1381,11 @@ static void __init arch_reserve_crashkernel(void)
 	if (ret)
 		return;
 
+	if (crash_size >= memblock_phys_mem_size()) {
+		pr_warn("Crashkernel: invalid size.");
+		return;
+	}
+
 	reserve_crashkernel_generic(cmdline, crash_size, crash_base,
 				    low_size, high);
 }
-- 
2.34.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ