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: <20251113155104.226617-5-yuntao.wang@linux.dev>
Date: Thu, 13 Nov 2025 23:51:01 +0800
From: Yuntao Wang <yuntao.wang@...ux.dev>
To: Rob Herring <robh@...nel.org>,
	Saravana Kannan <saravanak@...gle.com>
Cc: Geert Uytterhoeven <geert+renesas@...der.be>,
	Catalin Marinas <catalin.marinas@....com>,
	James Morse <james.morse@....com>,
	Baoquan He <bhe@...hat.com>,
	Zhen Lei <thunder.leizhen@...wei.com>,
	Ard Biesheuvel <ardb@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Geoff Levand <geoff@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Changyuan Lyu <changyuanl@...gle.com>,
	Alexander Graf <graf@...zon.com>,
	"Mike Rapoport (Microsoft)" <rppt@...nel.org>,
	devicetree@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Yuntao Wang <yuntao.wang@...ux.dev>
Subject: [PATCH v2 4/7] of/fdt: Fix incorrect use of dt_root_addr_cells in early_init_dt_check_kho()

When reading the fdt_size value, the argument passed to dt_mem_next_cell()
is dt_root_addr_cells, but it should be dt_root_size_cells.

The same issue occurs when reading the scratch_size value.

Use a helper function to simplify the code and fix these issues.

Fixes: 274cdcb1c004 ("arm64: add KHO support")
Signed-off-by: Yuntao Wang <yuntao.wang@...ux.dev>
---
 drivers/of/fdt.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index d0caaab42aa7..4c45a97d6652 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -918,26 +918,16 @@ static void __init early_init_dt_check_kho(void)
 {
 	unsigned long node = chosen_node_offset;
 	u64 fdt_start, fdt_size, scratch_start, scratch_size;
-	const __be32 *p;
-	int l;
 
 	if (!IS_ENABLED(CONFIG_KEXEC_HANDOVER) || (long)node < 0)
 		return;
 
-	p = of_get_flat_dt_prop(node, "linux,kho-fdt", &l);
-	if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32))
+	if (!of_fdt_get_addr_size(node, "linux,kho-fdt", &fdt_start, &fdt_size))
 		return;
 
-	fdt_start = dt_mem_next_cell(dt_root_addr_cells, &p);
-	fdt_size = dt_mem_next_cell(dt_root_addr_cells, &p);
-
-	p = of_get_flat_dt_prop(node, "linux,kho-scratch", &l);
-	if (l != (dt_root_addr_cells + dt_root_size_cells) * sizeof(__be32))
+	if (!of_fdt_get_addr_size(node, "linux,kho-scratch", &scratch_start, &scratch_size))
 		return;
 
-	scratch_start = dt_mem_next_cell(dt_root_addr_cells, &p);
-	scratch_size = dt_mem_next_cell(dt_root_addr_cells, &p);
-
 	kho_populate(fdt_start, fdt_size, scratch_start, scratch_size);
 }
 
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ