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]
Date: Sun, 12 May 2024 15:25:09 +0200
From: Christian Marangi <ansuelsmth@...il.com>
To: Rob Herring <robh@...nel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
	Conor Dooley <conor+dt@...nel.org>,
	Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
	Saravana Kannan <saravanak@...gle.com>,
	Arnd Bergmann <arnd@...db.de>,
	Helge Deller <deller@....de>,
	Javier Martinez Canillas <javierm@...hat.com>,
	Baoquan He <bhe@...hat.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	Jiaxun Yang <jiaxun.yang@...goat.com>,
	David Bauer <mail@...id-bauer.net>,
	Liviu Dudau <liviu@...au.co.uk>,
	Serge Semin <fancer.lancer@...il.com>,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	linux-mips@...r.kernel.org
Cc: Christian Marangi <ansuelsmth@...il.com>
Subject: [PATCH 2/4] of: add support for bootargs-override chosen property

On some devices bootloader may hardcoded and overwrite the
bootargs DT property passed in "/chosen" when the kernel is
loaded resulting in the value dropped.

While CMDLINE_FORCE can be used, this is not a good option for
kernels that are shared across devices.

This setting enables using "/chosen/bootargs-override" as the
cmdline if it exists in the device tree.

This broken behaviour was found in various devices from ipq806x Soc,
to Mediatek and even PowerPC.

Signed-off-by: Christian Marangi <ansuelsmth@...il.com>
---
 drivers/of/fdt.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a8a04f27915b..253315421591 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -1068,8 +1068,16 @@ int __init early_init_dt_scan_chosen(char *cmdline)
 				fdt_totalsize(initial_boot_params));
 	}
 
-	/* Retrieve command line */
-	p = of_get_flat_dt_prop(node, "bootargs", &l);
+	/*
+	 * Retrieve command line
+	 * bootargs might be hardcoded and overwrite by bootloader on
+	 * kernel load.
+	 * Check if alternative bootargs-override is present instead
+	 * first.
+	 */
+	p = of_get_flat_dt_prop(node, "bootargs-override", &l);
+	if (p == NULL || l == 0)
+		p = of_get_flat_dt_prop(node, "bootargs", &l);
 	if (p != NULL && l > 0)
 		strscpy(cmdline, p, min(l, COMMAND_LINE_SIZE));
 
-- 
2.43.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ