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>] [day] [month] [year] [list]
Date:   Thu, 4 Apr 2019 17:18:20 +0200
From:   Horatiu Vultur <horatiu.vultur@...rochip.com>
To:     <ralf@...ux-mips.org>, <paul.burton@...s.com>, <jhogan@...nel.org>,
        <linux-mips@...r.kernel.org>, <linux-kernel@...r.kernel.org>
CC:     Horatiu Vultur <horatiu.vultur@...rochip.com>
Subject: [PATCH] arch: mips: Fix initrd_start and initrd_end when read from DT

When the bootloader passes arguments to linux kernel through device tree,
it passes the address of initrd_start and initrd_stop, which are in kseg0.
But when linux kernel reads these addresses from device tree, it converts
them to virtual addresses inside the function
__early_init_dt_declare_initrd.

At a later point then in the function init_initrd, it is checking for
initrd_start to be lower than PAGE_OFFSET, which for a 32 CPU it is not,
therefore it would disable the initrd by setting 0 to initrd_start and
initrd_stop.

The fix consists of checking if linux kernel received a device tree and not
having enable extended virtual address and in that case convert them back
to physical addresses that point in kseg0 as expected.

Signed-off-by: Horatiu Vultur <horatiu.vultur@...rochip.com>
---
 arch/mips/kernel/setup.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 8d1dc6c..b232784 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -264,6 +264,17 @@ static unsigned long __init init_initrd(void)
 		pr_err("initrd start must be page aligned\n");
 		goto disable;
 	}
+
+	/*
+	 * In case the initrd_start and initrd_end are read from DT,
+	 * then they are converted to virtual address, therefore convert
+	 * them back to physical address.
+	 */
+	if (!IS_ENABLED(CONFIG_EVA) && fw_arg0 == -2) {
+		initrd_start = __pa(initrd_start);
+		initrd_end = __pa(initrd_end);
+	}
+
 	if (initrd_start < PAGE_OFFSET) {
 		pr_err("initrd start < PAGE_OFFSET\n");
 		goto disable;
-- 
2.7.4

Powered by blists - more mailing lists