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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240821-save_resv_name-v1-1-b9c17f103ffb@flygoat.com>
Date: Wed, 21 Aug 2024 14:51:02 +0100
From: Jiaxun Yang <jiaxun.yang@...goat.com>
To: Rob Herring <robh@...nel.org>, Saravana Kannan <saravanak@...gle.com>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org, 
 loongarch@...ts.linux.dev, chenhuacai@...nel.org, 
 Kevin Wheatfox <enkerewpo@...mail.com>, 
 Jiaxun Yang <jiaxun.yang@...goat.com>
Subject: [PATCH] of_reserved_mem: Save region name string into struct
 reserved_mem

Previously only a pointer to fdt string pool is saved to struct
reserved_mem as region name.

As on some architectures booting FDT will be wiped at later initialisation
stages, this is breaking reserved_mem users.

Copy and save the whole string into struct reserved_mem to avoid
FDT lifecycle problem.

Reported-by: Kevin Wheatfox <enkerewpo@...mail.com>
Closes: https://lore.kernel.org/loongarch/ME4P282MB1397447C3C094554C7AF2E37B58E2@ME4P282MB1397.AUSP282.PROD.OUTLOOK.COM/
Signed-off-by: Jiaxun Yang <jiaxun.yang@...goat.com>
---
 drivers/of/of_reserved_mem.c    | 2 +-
 include/linux/of_reserved_mem.h | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
index 46e1c3fbc769..22841599cd83 100644
--- a/drivers/of/of_reserved_mem.c
+++ b/drivers/of/of_reserved_mem.c
@@ -70,7 +70,7 @@ static void __init fdt_reserved_mem_save_node(unsigned long node, const char *un
 	}
 
 	rmem->fdt_node = node;
-	rmem->name = uname;
+	strscpy(rmem->name, uname, RESERVED_MEM_NAME_LEN);
 	rmem->base = base;
 	rmem->size = size;
 
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h
index e338282da652..ed9de36c9cc9 100644
--- a/include/linux/of_reserved_mem.h
+++ b/include/linux/of_reserved_mem.h
@@ -8,8 +8,10 @@
 struct of_phandle_args;
 struct reserved_mem_ops;
 
+#define RESERVED_MEM_NAME_LEN	128
+
 struct reserved_mem {
-	const char			*name;
+	char				name[RESERVED_MEM_NAME_LEN];
 	unsigned long			fdt_node;
 	const struct reserved_mem_ops	*ops;
 	phys_addr_t			base;

---
base-commit: bb1b0acdcd66e0d8eedee3570d249e076b89ab32
change-id: 20240821-save_resv_name-4f2e2cb8883b

Best regards,
-- 
Jiaxun Yang <jiaxun.yang@...goat.com>


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ