linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup()
@ 2025-08-17 18:37 Thorsten Blum
  2025-08-17 18:37 ` [PATCH 2/8] MIPS: sgi-ip32: " Thorsten Blum
                   ` (8 more replies)
  0 siblings, 9 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Thorsten Blum
  Cc: linux-hardening, linux-mips, linux-kernel

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/sgi-ip22/ip22-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
index e06a818fe792..f083b25be13b 100644
--- a/arch/mips/sgi-ip22/ip22-setup.c
+++ b/arch/mips/sgi-ip22/ip22-setup.c
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <linux/console.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 #include <linux/tty.h>
 
 #include <asm/addrspace.h>
@@ -65,7 +66,7 @@ void __init plat_mem_setup(void)
 		static char options[8] __initdata;
 		char *baud = ArcGetEnvironmentVariable("dbaud");
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
 				      baud ? options : NULL);
 	} else if (!ctype || *ctype != 'g') {
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-18 23:40   ` Justin Stitt
  2025-08-29 10:25   ` Thomas Bogendoerfer
  2025-08-17 18:37 ` [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup() Thorsten Blum
                   ` (7 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Thorsten Blum
  Cc: linux-hardening, linux-mips, linux-kernel

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
index aeb0805aae57..c2ebc4bbd866 100644
--- a/arch/mips/sgi-ip32/ip32-setup.c
+++ b/arch/mips/sgi-ip32/ip32-setup.c
@@ -14,6 +14,7 @@
 #include <linux/interrupt.h>
 #include <linux/param.h>
 #include <linux/sched.h>
+#include <linux/string.h>
 
 #include <asm/bootinfo.h>
 #include <asm/mipsregs.h>
@@ -90,7 +91,7 @@ void __init plat_mem_setup(void)
 			static char options[8] __initdata;
 			char *baud = ArcGetEnvironmentVariable("dbaud");
 			if (baud)
-				strcpy(options, baud);
+				strscpy(options, baud);
 			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
 					      baud ? options : NULL);
 		}
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
  2025-08-17 18:37 ` [PATCH 2/8] MIPS: sgi-ip32: " Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-18 23:45   ` Justin Stitt
  2025-08-29 10:25   ` Thomas Bogendoerfer
  2025-08-17 18:37 ` [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy() Thorsten Blum
                   ` (6 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Thorsten Blum, Thomas Zimmermann
  Cc: linux-hardening, linux-mips, linux-kernel

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/sni/setup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
index 03cb69937258..fc7da12284f5 100644
--- a/arch/mips/sni/setup.c
+++ b/arch/mips/sni/setup.c
@@ -13,6 +13,7 @@
 #include <linux/export.h>
 #include <linux/console.h>
 #include <linux/screen_info.h>
+#include <linux/string.h>
 
 #ifdef CONFIG_FW_ARC
 #include <asm/fw/arc/types.h>
@@ -80,7 +81,7 @@ static void __init sni_console_setup(void)
 			break;
 		}
 		if (baud)
-			strcpy(options, baud);
+			strscpy(options, baud);
 		if (strncmp(cdev, "tty552", 6) == 0)
 			add_preferred_console("ttyS", port,
 					      baud ? options : NULL);
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
  2025-08-17 18:37 ` [PATCH 2/8] MIPS: sgi-ip32: " Thorsten Blum
  2025-08-17 18:37 ` [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup() Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-18  6:30   ` Geert Uytterhoeven
  2025-08-29 10:25   ` Thomas Bogendoerfer
  2025-08-17 18:37 ` [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy() Thorsten Blum
                   ` (5 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Bartosz Golaszewski, Geert Uytterhoeven,
	Thorsten Blum, Linus Walleij
  Cc: linux-hardening, linux-mips, linux-kernel

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/txx9/generic/setup.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 5dc867ea2c69..03f8a3a95637 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -200,7 +200,7 @@ static void __init preprocess_cmdline(void)
 	static char cmdline[COMMAND_LINE_SIZE] __initdata;
 	char *s;
 
-	strcpy(cmdline, arcs_cmdline);
+	strscpy(cmdline, arcs_cmdline);
 	s = cmdline;
 	arcs_cmdline[0] = '\0';
 	while (s && *s) {
@@ -270,7 +270,7 @@ void __init prom_init(void)
 	preprocess_cmdline();
 	select_board();
 
-	strcpy(txx9_system_type, txx9_board_vec->system);
+	strscpy(txx9_system_type, txx9_board_vec->system);
 
 	txx9_board_vec->prom_init();
 }
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
                   ` (2 preceding siblings ...)
  2025-08-17 18:37 ` [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy() Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-18 23:58   ` Justin Stitt
  2025-08-29 10:26   ` Thomas Bogendoerfer
  2025-08-17 18:37 ` [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad() Thorsten Blum
                   ` (4 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Thorsten Blum
  Cc: linux-hardening, linux-mips, linux-kernel

strcpy() is deprecated; use memcpy() instead.

Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch
warning.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/fw/arc/cmdline.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/arch/mips/fw/arc/cmdline.c b/arch/mips/fw/arc/cmdline.c
index 155c5e911723..86b0e377b713 100644
--- a/arch/mips/fw/arc/cmdline.c
+++ b/arch/mips/fw/arc/cmdline.c
@@ -42,12 +42,13 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 {
 	char *s;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
 	while (actr < argc) {
-		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
-			int len = strlen(used_arc[i][0]);
+		for (i = 0; i < ARRAY_SIZE(used_arc); i++) {
+			len = strlen(used_arc[i][0]);
 
 			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
 			/* Ok, we want it. First append the replacement... */
@@ -57,8 +58,9 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
 				s = strchr(prom_argv(actr), '=');
 				if (s) {
 					s++;
-					strcpy(cp, s);
-					cp += strlen(s);
+					len = strlen(s);
+					memcpy(cp, s, len + 1);
+					cp += len;
 				}
 				*cp++ = ' ';
 				break;
@@ -74,6 +76,7 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 {
 	char *cp;
 	int actr, i;
+	size_t len;
 
 	actr = 1; /* Always ignore argv[0] */
 
@@ -86,14 +89,15 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 
 	while (actr < argc) {
 		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
-			int len = strlen(ignored[i]);
-
+			len = strlen(ignored[i]);
 			if (!strncmp(prom_argv(actr), ignored[i], len))
 				goto pic_cont;
 		}
+
 		/* Ok, we want it. */
-		strcpy(cp, prom_argv(actr));
-		cp += strlen(prom_argv(actr));
+		len = strlen(prom_argv(actr));
+		memcpy(cp, prom_argv(actr), len + 1);
+		cp += len;
 		*cp++ = ' ';
 
 	pic_cont:
@@ -105,6 +109,6 @@ void __init prom_init_cmdline(int argc, LONG *argv)
 	*cp = '\0';
 
 #ifdef DEBUG_CMDLINE
-	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
+	pr_debug("prom cmdline: %s\n", arcs_cmdline);
 #endif
 }
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
                   ` (3 preceding siblings ...)
  2025-08-17 18:37 ` [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy() Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-19  0:02   ` Justin Stitt
  2025-08-29 10:26   ` Thomas Bogendoerfer
  2025-08-17 18:37 ` [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer() Thorsten Blum
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Thorsten Blum
  Cc: linux-hardening, linux-mips, linux-kernel

Replace memset(0) followed by the deprecated strcpy() with strscpy_pad()
to improve octeon_fdt_set_phy(). This avoids zeroing the memory before
copying the string and ensures the destination buffer is only written to
once, simplifying the code and improving efficiency.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/cavium-octeon/octeon-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
index 5e1dd4e6e82f..47677b5d7ed0 100644
--- a/arch/mips/cavium-octeon/octeon-platform.c
+++ b/arch/mips/cavium-octeon/octeon-platform.c
@@ -13,6 +13,7 @@
 #include <linux/of_fdt.h>
 #include <linux/platform_device.h>
 #include <linux/libfdt.h>
+#include <linux/string.h>
 
 #include <asm/octeon/octeon.h>
 #include <asm/octeon/cvmx-helper-board.h>
@@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
 
 	if (octeon_has_88e1145()) {
 		fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
-		memset(new_name, 0, sizeof(new_name));
-		strcpy(new_name, "marvell,88e1145");
+		strscpy_pad(new_name, "marvell,88e1145");
 		p = fdt_getprop(initial_boot_params, phy, "compatible",
 				&current_len);
 		if (p && current_len >= strlen(new_name))
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
                   ` (4 preceding siblings ...)
  2025-08-17 18:37 ` [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad() Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-29 10:26   ` Thomas Bogendoerfer
  2025-08-17 18:37 ` [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect() Thorsten Blum
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Thomas Bogendoerfer, Thorsten Blum
  Cc: linux-hardening, linux-mips, linux-kernel

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 .../cavium-octeon/executive/octeon-model.c    | 31 ++++++++++---------
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/mips/cavium-octeon/executive/octeon-model.c b/arch/mips/cavium-octeon/executive/octeon-model.c
index 657dbad9644e..98996cc0857e 100644
--- a/arch/mips/cavium-octeon/executive/octeon-model.c
+++ b/arch/mips/cavium-octeon/executive/octeon-model.c
@@ -25,6 +25,7 @@
  * Contact Cavium Networks for more information
  ***********************license end**************************************/
 
+#include <linux/string.h>
 #include <asm/octeon/octeon.h>
 
 enum octeon_feature_bits __octeon_feature_bits __read_mostly;
@@ -208,16 +209,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.X");
+			strscpy(pass, "1.X");
 			break;
 		case 1:
-			strcpy(pass, "2.X");
+			strscpy(pass, "2.X");
 			break;
 		case 3:
-			strcpy(pass, "3.X");
+			strscpy(pass, "3.X");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -232,13 +233,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.0");
+			strscpy(pass, "1.0");
 			break;
 		case 2:
-			strcpy(pass, "1.1");
+			strscpy(pass, "1.1");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -253,13 +254,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		 */
 		switch (chip_id & 0xf) {
 		case 0:
-			strcpy(pass, "1.0");
+			strscpy(pass, "1.0");
 			break;
 		case 2:
-			strcpy(pass, "1.1");
+			strscpy(pass, "1.1");
 			break;
 		default:
-			strcpy(pass, "X.X");
+			strscpy(pass, "X.X");
 			break;
 		}
 		break;
@@ -273,16 +274,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 		if ((chip_id & 0xFF) < 0x8) {
 			switch (chip_id & 0x3) {
 			case 0:
-				strcpy(pass, "1.0");
+				strscpy(pass, "1.0");
 				break;
 			case 1:
-				strcpy(pass, "1.1");
+				strscpy(pass, "1.1");
 				break;
 			case 3:
-				strcpy(pass, "1.2");
+				strscpy(pass, "1.2");
 				break;
 			default:
-				strcpy(pass, "1.X");
+				strscpy(pass, "1.X");
 				break;
 			}
 		}
@@ -447,7 +448,7 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
 	default:
 		family = "XX";
 		core_model = "XX";
-		strcpy(pass, "X.X");
+		strscpy(pass, "X.X");
 		suffix = "XXX";
 		break;
 	}
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
                   ` (5 preceding siblings ...)
  2025-08-17 18:37 ` [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer() Thorsten Blum
@ 2025-08-17 18:37 ` Thorsten Blum
  2025-08-29 10:27   ` Thomas Bogendoerfer
  2025-08-18 23:24 ` [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Justin Stitt
  2025-08-29 10:25 ` Thomas Bogendoerfer
  8 siblings, 1 reply; 24+ messages in thread
From: Thorsten Blum @ 2025-08-17 18:37 UTC (permalink / raw)
  To: Alexandre Belloni, UNGLinuxDriver, Paul Burton,
	Thomas Bogendoerfer
  Cc: linux-hardening, Thorsten Blum, linux-mips, linux-kernel

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/generic/board-ocelot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/generic/board-ocelot.c b/arch/mips/generic/board-ocelot.c
index 7115410acb4f..59a0fb243582 100644
--- a/arch/mips/generic/board-ocelot.c
+++ b/arch/mips/generic/board-ocelot.c
@@ -4,6 +4,7 @@
  *
  * Copyright (c) 2017 Microsemi Corporation
  */
+#include <linux/string.h>
 #include <asm/machine.h>
 #include <asm/prom.h>
 
@@ -41,7 +42,7 @@ static __init bool ocelot_detect(void)
 
 		if (prom_argc > 1 && strlen(prom_argv[1]) > 0)
 			/* ignore all built-in args if any f/w args given */
-			strcpy(arcs_cmdline, prom_argv[1]);
+			strscpy(arcs_cmdline, prom_argv[1]);
 	}
 
 	return true;
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 24+ messages in thread

* Re: [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy()
  2025-08-17 18:37 ` [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy() Thorsten Blum
@ 2025-08-18  6:30   ` Geert Uytterhoeven
  2025-08-29 10:25   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Geert Uytterhoeven @ 2025-08-18  6:30 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Bogendoerfer, Bartosz Golaszewski, Linus Walleij,
	linux-hardening, linux-mips, linux-kernel

On Sun, 17 Aug 2025 at 20:38, Thorsten Blum <thorsten.blum@linux.dev> wrote:
> strcpy() is deprecated; use strscpy() instead.
>
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
                   ` (6 preceding siblings ...)
  2025-08-17 18:37 ` [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect() Thorsten Blum
@ 2025-08-18 23:24 ` Justin Stitt
  2025-08-29 10:25 ` Thomas Bogendoerfer
  8 siblings, 0 replies; 24+ messages in thread
From: Justin Stitt @ 2025-08-18 23:24 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Bogendoerfer, linux-hardening, linux-mips, linux-kernel

Hi,

On Sun, Aug 17, 2025 at 08:37:11PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Justin Stitt <justinstitt@google.com>

> ---
>  arch/mips/sgi-ip22/ip22-setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
> index e06a818fe792..f083b25be13b 100644
> --- a/arch/mips/sgi-ip22/ip22-setup.c
> +++ b/arch/mips/sgi-ip22/ip22-setup.c
> @@ -11,6 +11,7 @@
>  #include <linux/types.h>
>  #include <linux/console.h>
>  #include <linux/sched.h>
> +#include <linux/string.h>
>  #include <linux/tty.h>
>  
>  #include <asm/addrspace.h>
> @@ -65,7 +66,7 @@ void __init plat_mem_setup(void)
>  		static char options[8] __initdata;
>  		char *baud = ArcGetEnvironmentVariable("dbaud");
>  		if (baud)
> -			strcpy(options, baud);
> +			strscpy(options, baud);
>  		add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
>  				      baud ? options : NULL);
>  	} else if (!ctype || *ctype != 'g') {
> -- 
> 2.50.1
> 
>

Thanks
Justin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()
  2025-08-17 18:37 ` [PATCH 2/8] MIPS: sgi-ip32: " Thorsten Blum
@ 2025-08-18 23:40   ` Justin Stitt
  2025-08-19  0:33     ` Thorsten Blum
  2025-08-29 10:25   ` Thomas Bogendoerfer
  1 sibling, 1 reply; 24+ messages in thread
From: Justin Stitt @ 2025-08-18 23:40 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Bogendoerfer, linux-hardening, linux-mips, linux-kernel

Hi,

On Sun, Aug 17, 2025 at 08:37:12PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
> index aeb0805aae57..c2ebc4bbd866 100644
> --- a/arch/mips/sgi-ip32/ip32-setup.c
> +++ b/arch/mips/sgi-ip32/ip32-setup.c
> @@ -14,6 +14,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/param.h>
>  #include <linux/sched.h>
> +#include <linux/string.h>

This new include isn't strictly necessary as it was building with
strcpy() fine before?

>  
>  #include <asm/bootinfo.h>
>  #include <asm/mipsregs.h>
> @@ -90,7 +91,7 @@ void __init plat_mem_setup(void)
>  			static char options[8] __initdata;
>  			char *baud = ArcGetEnvironmentVariable("dbaud");
>  			if (baud)
> -				strcpy(options, baud);
> +				strscpy(options, baud);
>  			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
>  					      baud ? options : NULL);
>  		}
> -- 
> 2.50.1
> 
>

Thanks
Justin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup()
  2025-08-17 18:37 ` [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup() Thorsten Blum
@ 2025-08-18 23:45   ` Justin Stitt
  2025-08-29 10:25   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Justin Stitt @ 2025-08-18 23:45 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Bogendoerfer, Thomas Zimmermann, linux-hardening,
	linux-mips, linux-kernel

Hi,

On Sun, Aug 17, 2025 at 08:37:13PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/sni/setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
> index 03cb69937258..fc7da12284f5 100644
> --- a/arch/mips/sni/setup.c
> +++ b/arch/mips/sni/setup.c
> @@ -13,6 +13,7 @@
>  #include <linux/export.h>
>  #include <linux/console.h>
>  #include <linux/screen_info.h>
> +#include <linux/string.h>

This include isn't strictly necessary but I suppose it makes the
dependency explicit.

Reviewed-by: Justin Stitt <justinstitt@google.com>

>  
>  #ifdef CONFIG_FW_ARC
>  #include <asm/fw/arc/types.h>
> @@ -80,7 +81,7 @@ static void __init sni_console_setup(void)
>  			break;
>  		}
>  		if (baud)
> -			strcpy(options, baud);
> +			strscpy(options, baud);
>  		if (strncmp(cdev, "tty552", 6) == 0)
>  			add_preferred_console("ttyS", port,
>  					      baud ? options : NULL);
> -- 
> 2.50.1
> 
>

Thanks
Justin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()
  2025-08-17 18:37 ` [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy() Thorsten Blum
@ 2025-08-18 23:58   ` Justin Stitt
  2025-08-19 10:00     ` Thorsten Blum
  2025-08-29 10:26   ` Thomas Bogendoerfer
  1 sibling, 1 reply; 24+ messages in thread
From: Justin Stitt @ 2025-08-18 23:58 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Bogendoerfer, linux-hardening, linux-mips, linux-kernel

Hi,

On Sun, Aug 17, 2025 at 08:37:15PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use memcpy() instead.
> 
> Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch
> warning.

I'd like to see more reasoning for why you chose memcpy() here. With api
refactors like this I think most folks want to know if 1) there is any
functional change and 2) why you chose the api.

> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/fw/arc/cmdline.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/mips/fw/arc/cmdline.c b/arch/mips/fw/arc/cmdline.c
> index 155c5e911723..86b0e377b713 100644
> --- a/arch/mips/fw/arc/cmdline.c
> +++ b/arch/mips/fw/arc/cmdline.c
> @@ -42,12 +42,13 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
>  {
>  	char *s;
>  	int actr, i;
> +	size_t len;
>  
>  	actr = 1; /* Always ignore argv[0] */
>  
>  	while (actr < argc) {
> -		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
> -			int len = strlen(used_arc[i][0]);
> +		for (i = 0; i < ARRAY_SIZE(used_arc); i++) {
> +			len = strlen(used_arc[i][0]);
>  
>  			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
>  			/* Ok, we want it. First append the replacement... */
> @@ -57,8 +58,9 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
>  				s = strchr(prom_argv(actr), '=');
>  				if (s) {
>  					s++;
> -					strcpy(cp, s);
> -					cp += strlen(s);
> +					len = strlen(s);
> +					memcpy(cp, s, len + 1);
> +					cp += len;
>  				}
>  				*cp++ = ' ';
>  				break;
> @@ -74,6 +76,7 @@ void __init prom_init_cmdline(int argc, LONG *argv)
>  {
>  	char *cp;
>  	int actr, i;
> +	size_t len;
>  
>  	actr = 1; /* Always ignore argv[0] */
>  
> @@ -86,14 +89,15 @@ void __init prom_init_cmdline(int argc, LONG *argv)
>  
>  	while (actr < argc) {
>  		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
> -			int len = strlen(ignored[i]);
> -
> +			len = strlen(ignored[i]);
>  			if (!strncmp(prom_argv(actr), ignored[i], len))
>  				goto pic_cont;
>  		}
> +
>  		/* Ok, we want it. */
> -		strcpy(cp, prom_argv(actr));
> -		cp += strlen(prom_argv(actr));
> +		len = strlen(prom_argv(actr));
> +		memcpy(cp, prom_argv(actr), len + 1);
> +		cp += len;
>  		*cp++ = ' ';
>  
>  	pic_cont:
> @@ -105,6 +109,6 @@ void __init prom_init_cmdline(int argc, LONG *argv)
>  	*cp = '\0';
>  
>  #ifdef DEBUG_CMDLINE
> -	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
> +	pr_debug("prom cmdline: %s\n", arcs_cmdline);
>  #endif
>  }
> -- 
> 2.50.1
> 
>

Thanks
Justin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()
  2025-08-17 18:37 ` [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad() Thorsten Blum
@ 2025-08-19  0:02   ` Justin Stitt
  2025-08-29 10:26   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Justin Stitt @ 2025-08-19  0:02 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Bogendoerfer, linux-hardening, linux-mips, linux-kernel

Hi,

On Sun, Aug 17, 2025 at 08:37:16PM +0200, Thorsten Blum wrote:
> Replace memset(0) followed by the deprecated strcpy() with strscpy_pad()
> to improve octeon_fdt_set_phy(). This avoids zeroing the memory before
> copying the string and ensures the destination buffer is only written to
> once, simplifying the code and improving efficiency.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>

Reviewed-by: Justin Stitt <justinstitt@google.com>

> ---
>  arch/mips/cavium-octeon/octeon-platform.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
> index 5e1dd4e6e82f..47677b5d7ed0 100644
> --- a/arch/mips/cavium-octeon/octeon-platform.c
> +++ b/arch/mips/cavium-octeon/octeon-platform.c
> @@ -13,6 +13,7 @@
>  #include <linux/of_fdt.h>
>  #include <linux/platform_device.h>
>  #include <linux/libfdt.h>
> +#include <linux/string.h>
>  
>  #include <asm/octeon/octeon.h>
>  #include <asm/octeon/cvmx-helper-board.h>
> @@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
>  
>  	if (octeon_has_88e1145()) {
>  		fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
> -		memset(new_name, 0, sizeof(new_name));
> -		strcpy(new_name, "marvell,88e1145");
> +		strscpy_pad(new_name, "marvell,88e1145");
>  		p = fdt_getprop(initial_boot_params, phy, "compatible",
>  				&current_len);
>  		if (p && current_len >= strlen(new_name))
> -- 
> 2.50.1
> 
>

Thanks
Justin

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()
  2025-08-18 23:40   ` Justin Stitt
@ 2025-08-19  0:33     ` Thorsten Blum
  0 siblings, 0 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-19  0:33 UTC (permalink / raw)
  To: Justin Stitt
  Cc: Thomas Bogendoerfer, linux-hardening, linux-mips, linux-kernel

On 19. Aug 2025, at 01:40, Justin Stitt wrote:
> On Sun, Aug 17, 2025 at 08:37:12PM +0200, Thorsten Blum wrote:
>> strcpy() is deprecated; use strscpy() instead.
>> 
>> Link: https://github.com/KSPP/linux/issues/88
>> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
>> ---
>> arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
>> index aeb0805aae57..c2ebc4bbd866 100644
>> --- a/arch/mips/sgi-ip32/ip32-setup.c
>> +++ b/arch/mips/sgi-ip32/ip32-setup.c
>> @@ -14,6 +14,7 @@
>> #include <linux/interrupt.h>
>> #include <linux/param.h>
>> #include <linux/sched.h>
>> +#include <linux/string.h>
> 
> This new include isn't strictly necessary as it was building with
> strcpy() fine before?

It's not strictly necessary, but since I was often asked to explicitly
include it, I made it a habit.

Best,
Thorsten


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()
  2025-08-18 23:58   ` Justin Stitt
@ 2025-08-19 10:00     ` Thorsten Blum
  0 siblings, 0 replies; 24+ messages in thread
From: Thorsten Blum @ 2025-08-19 10:00 UTC (permalink / raw)
  To: Justin Stitt
  Cc: Thomas Bogendoerfer, linux-hardening, linux-mips, linux-kernel

Hi Justin,

On 19. Aug 2025, at 01:58, Justin Stitt wrote:
> On Sun, Aug 17, 2025 at 08:37:15PM +0200, Thorsten Blum wrote:
>> strcpy() is deprecated; use memcpy() instead.
>> 
>> Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch
>> warning.
> 
> I'd like to see more reasoning for why you chose memcpy() here. With api
> refactors like this I think most folks want to know if 1) there is any
> functional change and 2) why you chose the api.

1) No functional changes intended.

2) To advance the pointer 'cp', we already determine the string length
'len' using strlen(), which allows us to use memcpy() directly. This is
slightly more efficient than strscpy(), which would recompute the length
before calling memcpy() internally. We could also use strscpy() and its
return value as the length, but that would require checking for string
truncation, which might introduce a functional change.

Thanks,
Thorsten


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup()
  2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
                   ` (7 preceding siblings ...)
  2025-08-18 23:24 ` [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Justin Stitt
@ 2025-08-29 10:25 ` Thomas Bogendoerfer
  8 siblings, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:25 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:11PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/sgi-ip22/ip22-setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sgi-ip22/ip22-setup.c b/arch/mips/sgi-ip22/ip22-setup.c
> index e06a818fe792..f083b25be13b 100644
> --- a/arch/mips/sgi-ip22/ip22-setup.c
> +++ b/arch/mips/sgi-ip22/ip22-setup.c
> @@ -11,6 +11,7 @@
>  #include <linux/types.h>
>  #include <linux/console.h>
>  #include <linux/sched.h>
> +#include <linux/string.h>
>  #include <linux/tty.h>
>  
>  #include <asm/addrspace.h>
> @@ -65,7 +66,7 @@ void __init plat_mem_setup(void)
>  		static char options[8] __initdata;
>  		char *baud = ArcGetEnvironmentVariable("dbaud");
>  		if (baud)
> -			strcpy(options, baud);
> +			strscpy(options, baud);
>  		add_preferred_console("ttyS", *(ctype + 1) == '2' ? 1 : 0,
>  				      baud ? options : NULL);
>  	} else if (!ctype || *ctype != 'g') {
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 2/8] MIPS: sgi-ip32: Replace deprecated strcpy() in plat_mem_setup()
  2025-08-17 18:37 ` [PATCH 2/8] MIPS: sgi-ip32: " Thorsten Blum
  2025-08-18 23:40   ` Justin Stitt
@ 2025-08-29 10:25   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:25 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:12PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/sgi-ip32/ip32-setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sgi-ip32/ip32-setup.c b/arch/mips/sgi-ip32/ip32-setup.c
> index aeb0805aae57..c2ebc4bbd866 100644
> --- a/arch/mips/sgi-ip32/ip32-setup.c
> +++ b/arch/mips/sgi-ip32/ip32-setup.c
> @@ -14,6 +14,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/param.h>
>  #include <linux/sched.h>
> +#include <linux/string.h>
>  
>  #include <asm/bootinfo.h>
>  #include <asm/mipsregs.h>
> @@ -90,7 +91,7 @@ void __init plat_mem_setup(void)
>  			static char options[8] __initdata;
>  			char *baud = ArcGetEnvironmentVariable("dbaud");
>  			if (baud)
> -				strcpy(options, baud);
> +				strscpy(options, baud);
>  			add_preferred_console("ttyS", *(con + 1) == '2' ? 1 : 0,
>  					      baud ? options : NULL);
>  		}
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup()
  2025-08-17 18:37 ` [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup() Thorsten Blum
  2025-08-18 23:45   ` Justin Stitt
@ 2025-08-29 10:25   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:25 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Thomas Zimmermann, linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:13PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/sni/setup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/sni/setup.c b/arch/mips/sni/setup.c
> index 03cb69937258..fc7da12284f5 100644
> --- a/arch/mips/sni/setup.c
> +++ b/arch/mips/sni/setup.c
> @@ -13,6 +13,7 @@
>  #include <linux/export.h>
>  #include <linux/console.h>
>  #include <linux/screen_info.h>
> +#include <linux/string.h>
>  
>  #ifdef CONFIG_FW_ARC
>  #include <asm/fw/arc/types.h>
> @@ -80,7 +81,7 @@ static void __init sni_console_setup(void)
>  			break;
>  		}
>  		if (baud)
> -			strcpy(options, baud);
> +			strscpy(options, baud);
>  		if (strncmp(cdev, "tty552", 6) == 0)
>  			add_preferred_console("ttyS", port,
>  					      baud ? options : NULL);
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy()
  2025-08-17 18:37 ` [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy() Thorsten Blum
  2025-08-18  6:30   ` Geert Uytterhoeven
@ 2025-08-29 10:25   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:25 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Bartosz Golaszewski, Geert Uytterhoeven, Linus Walleij,
	linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:14PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/txx9/generic/setup.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
> index 5dc867ea2c69..03f8a3a95637 100644
> --- a/arch/mips/txx9/generic/setup.c
> +++ b/arch/mips/txx9/generic/setup.c
> @@ -200,7 +200,7 @@ static void __init preprocess_cmdline(void)
>  	static char cmdline[COMMAND_LINE_SIZE] __initdata;
>  	char *s;
>  
> -	strcpy(cmdline, arcs_cmdline);
> +	strscpy(cmdline, arcs_cmdline);
>  	s = cmdline;
>  	arcs_cmdline[0] = '\0';
>  	while (s && *s) {
> @@ -270,7 +270,7 @@ void __init prom_init(void)
>  	preprocess_cmdline();
>  	select_board();
>  
> -	strcpy(txx9_system_type, txx9_board_vec->system);
> +	strscpy(txx9_system_type, txx9_board_vec->system);
>  
>  	txx9_board_vec->prom_init();
>  }
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy()
  2025-08-17 18:37 ` [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy() Thorsten Blum
  2025-08-18 23:58   ` Justin Stitt
@ 2025-08-29 10:26   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:26 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:15PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use memcpy() instead.
> 
> Use pr_debug() instead of printk(KERN_DEBUG) to silence a checkpatch
> warning.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/fw/arc/cmdline.c | 22 +++++++++++++---------
>  1 file changed, 13 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/mips/fw/arc/cmdline.c b/arch/mips/fw/arc/cmdline.c
> index 155c5e911723..86b0e377b713 100644
> --- a/arch/mips/fw/arc/cmdline.c
> +++ b/arch/mips/fw/arc/cmdline.c
> @@ -42,12 +42,13 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
>  {
>  	char *s;
>  	int actr, i;
> +	size_t len;
>  
>  	actr = 1; /* Always ignore argv[0] */
>  
>  	while (actr < argc) {
> -		for(i = 0; i < ARRAY_SIZE(used_arc); i++) {
> -			int len = strlen(used_arc[i][0]);
> +		for (i = 0; i < ARRAY_SIZE(used_arc); i++) {
> +			len = strlen(used_arc[i][0]);
>  
>  			if (!strncmp(prom_argv(actr), used_arc[i][0], len)) {
>  			/* Ok, we want it. First append the replacement... */
> @@ -57,8 +58,9 @@ static char __init *move_firmware_args(int argc, LONG *argv, char *cp)
>  				s = strchr(prom_argv(actr), '=');
>  				if (s) {
>  					s++;
> -					strcpy(cp, s);
> -					cp += strlen(s);
> +					len = strlen(s);
> +					memcpy(cp, s, len + 1);
> +					cp += len;
>  				}
>  				*cp++ = ' ';
>  				break;
> @@ -74,6 +76,7 @@ void __init prom_init_cmdline(int argc, LONG *argv)
>  {
>  	char *cp;
>  	int actr, i;
> +	size_t len;
>  
>  	actr = 1; /* Always ignore argv[0] */
>  
> @@ -86,14 +89,15 @@ void __init prom_init_cmdline(int argc, LONG *argv)
>  
>  	while (actr < argc) {
>  		for (i = 0; i < ARRAY_SIZE(ignored); i++) {
> -			int len = strlen(ignored[i]);
> -
> +			len = strlen(ignored[i]);
>  			if (!strncmp(prom_argv(actr), ignored[i], len))
>  				goto pic_cont;
>  		}
> +
>  		/* Ok, we want it. */
> -		strcpy(cp, prom_argv(actr));
> -		cp += strlen(prom_argv(actr));
> +		len = strlen(prom_argv(actr));
> +		memcpy(cp, prom_argv(actr), len + 1);
> +		cp += len;
>  		*cp++ = ' ';
>  
>  	pic_cont:
> @@ -105,6 +109,6 @@ void __init prom_init_cmdline(int argc, LONG *argv)
>  	*cp = '\0';
>  
>  #ifdef DEBUG_CMDLINE
> -	printk(KERN_DEBUG "prom cmdline: %s\n", arcs_cmdline);
> +	pr_debug("prom cmdline: %s\n", arcs_cmdline);
>  #endif
>  }
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad()
  2025-08-17 18:37 ` [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad() Thorsten Blum
  2025-08-19  0:02   ` Justin Stitt
@ 2025-08-29 10:26   ` Thomas Bogendoerfer
  1 sibling, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:26 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:16PM +0200, Thorsten Blum wrote:
> Replace memset(0) followed by the deprecated strcpy() with strscpy_pad()
> to improve octeon_fdt_set_phy(). This avoids zeroing the memory before
> copying the string and ensures the destination buffer is only written to
> once, simplifying the code and improving efficiency.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/cavium-octeon/octeon-platform.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/mips/cavium-octeon/octeon-platform.c b/arch/mips/cavium-octeon/octeon-platform.c
> index 5e1dd4e6e82f..47677b5d7ed0 100644
> --- a/arch/mips/cavium-octeon/octeon-platform.c
> +++ b/arch/mips/cavium-octeon/octeon-platform.c
> @@ -13,6 +13,7 @@
>  #include <linux/of_fdt.h>
>  #include <linux/platform_device.h>
>  #include <linux/libfdt.h>
> +#include <linux/string.h>
>  
>  #include <asm/octeon/octeon.h>
>  #include <asm/octeon/cvmx-helper-board.h>
> @@ -538,8 +539,7 @@ static void __init octeon_fdt_set_phy(int eth, int phy_addr)
>  
>  	if (octeon_has_88e1145()) {
>  		fdt_nop_property(initial_boot_params, phy, "marvell,reg-init");
> -		memset(new_name, 0, sizeof(new_name));
> -		strcpy(new_name, "marvell,88e1145");
> +		strscpy_pad(new_name, "marvell,88e1145");
>  		p = fdt_getprop(initial_boot_params, phy, "compatible",
>  				&current_len);
>  		if (p && current_len >= strlen(new_name))
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer()
  2025-08-17 18:37 ` [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer() Thorsten Blum
@ 2025-08-29 10:26   ` Thomas Bogendoerfer
  0 siblings, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:26 UTC (permalink / raw)
  To: Thorsten Blum; +Cc: linux-hardening, linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:17PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  .../cavium-octeon/executive/octeon-model.c    | 31 ++++++++++---------
>  1 file changed, 16 insertions(+), 15 deletions(-)
> 
> diff --git a/arch/mips/cavium-octeon/executive/octeon-model.c b/arch/mips/cavium-octeon/executive/octeon-model.c
> index 657dbad9644e..98996cc0857e 100644
> --- a/arch/mips/cavium-octeon/executive/octeon-model.c
> +++ b/arch/mips/cavium-octeon/executive/octeon-model.c
> @@ -25,6 +25,7 @@
>   * Contact Cavium Networks for more information
>   ***********************license end**************************************/
>  
> +#include <linux/string.h>
>  #include <asm/octeon/octeon.h>
>  
>  enum octeon_feature_bits __octeon_feature_bits __read_mostly;
> @@ -208,16 +209,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
>  		 */
>  		switch (chip_id & 0xf) {
>  		case 0:
> -			strcpy(pass, "1.X");
> +			strscpy(pass, "1.X");
>  			break;
>  		case 1:
> -			strcpy(pass, "2.X");
> +			strscpy(pass, "2.X");
>  			break;
>  		case 3:
> -			strcpy(pass, "3.X");
> +			strscpy(pass, "3.X");
>  			break;
>  		default:
> -			strcpy(pass, "X.X");
> +			strscpy(pass, "X.X");
>  			break;
>  		}
>  		break;
> @@ -232,13 +233,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
>  		 */
>  		switch (chip_id & 0xf) {
>  		case 0:
> -			strcpy(pass, "1.0");
> +			strscpy(pass, "1.0");
>  			break;
>  		case 2:
> -			strcpy(pass, "1.1");
> +			strscpy(pass, "1.1");
>  			break;
>  		default:
> -			strcpy(pass, "X.X");
> +			strscpy(pass, "X.X");
>  			break;
>  		}
>  		break;
> @@ -253,13 +254,13 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
>  		 */
>  		switch (chip_id & 0xf) {
>  		case 0:
> -			strcpy(pass, "1.0");
> +			strscpy(pass, "1.0");
>  			break;
>  		case 2:
> -			strcpy(pass, "1.1");
> +			strscpy(pass, "1.1");
>  			break;
>  		default:
> -			strcpy(pass, "X.X");
> +			strscpy(pass, "X.X");
>  			break;
>  		}
>  		break;
> @@ -273,16 +274,16 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
>  		if ((chip_id & 0xFF) < 0x8) {
>  			switch (chip_id & 0x3) {
>  			case 0:
> -				strcpy(pass, "1.0");
> +				strscpy(pass, "1.0");
>  				break;
>  			case 1:
> -				strcpy(pass, "1.1");
> +				strscpy(pass, "1.1");
>  				break;
>  			case 3:
> -				strcpy(pass, "1.2");
> +				strscpy(pass, "1.2");
>  				break;
>  			default:
> -				strcpy(pass, "1.X");
> +				strscpy(pass, "1.X");
>  				break;
>  			}
>  		}
> @@ -447,7 +448,7 @@ static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
>  	default:
>  		family = "XX";
>  		core_model = "XX";
> -		strcpy(pass, "X.X");
> +		strscpy(pass, "X.X");
>  		suffix = "XXX";
>  		break;
>  	}
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect()
  2025-08-17 18:37 ` [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect() Thorsten Blum
@ 2025-08-29 10:27   ` Thomas Bogendoerfer
  0 siblings, 0 replies; 24+ messages in thread
From: Thomas Bogendoerfer @ 2025-08-29 10:27 UTC (permalink / raw)
  To: Thorsten Blum
  Cc: Alexandre Belloni, UNGLinuxDriver, Paul Burton, linux-hardening,
	linux-mips, linux-kernel

On Sun, Aug 17, 2025 at 08:37:18PM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/generic/board-ocelot.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/generic/board-ocelot.c b/arch/mips/generic/board-ocelot.c
> index 7115410acb4f..59a0fb243582 100644
> --- a/arch/mips/generic/board-ocelot.c
> +++ b/arch/mips/generic/board-ocelot.c
> @@ -4,6 +4,7 @@
>   *
>   * Copyright (c) 2017 Microsemi Corporation
>   */
> +#include <linux/string.h>
>  #include <asm/machine.h>
>  #include <asm/prom.h>
>  
> @@ -41,7 +42,7 @@ static __init bool ocelot_detect(void)
>  
>  		if (prom_argc > 1 && strlen(prom_argv[1]) > 0)
>  			/* ignore all built-in args if any f/w args given */
> -			strcpy(arcs_cmdline, prom_argv[1]);
> +			strscpy(arcs_cmdline, prom_argv[1]);
>  	}
>  
>  	return true;
> -- 
> 2.50.1

applied to mips-next.

Thomas.

-- 
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2025-08-29 10:31 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-17 18:37 [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Thorsten Blum
2025-08-17 18:37 ` [PATCH 2/8] MIPS: sgi-ip32: " Thorsten Blum
2025-08-18 23:40   ` Justin Stitt
2025-08-19  0:33     ` Thorsten Blum
2025-08-29 10:25   ` Thomas Bogendoerfer
2025-08-17 18:37 ` [PATCH 3/8] MIPS: sni: Replace deprecated strcpy() in sni_console_setup() Thorsten Blum
2025-08-18 23:45   ` Justin Stitt
2025-08-29 10:25   ` Thomas Bogendoerfer
2025-08-17 18:37 ` [PATCH 4/8] MIPS: txx9: Replace deprecated strcpy() with strscpy() Thorsten Blum
2025-08-18  6:30   ` Geert Uytterhoeven
2025-08-29 10:25   ` Thomas Bogendoerfer
2025-08-17 18:37 ` [PATCH 5/8] MIPS: arc: Replace deprecated strcpy() with memcpy() Thorsten Blum
2025-08-18 23:58   ` Justin Stitt
2025-08-19 10:00     ` Thorsten Blum
2025-08-29 10:26   ` Thomas Bogendoerfer
2025-08-17 18:37 ` [PATCH 6/8] MIPS: octeon: Replace memset(0) + deprecated strcpy() with strscpy_pad() Thorsten Blum
2025-08-19  0:02   ` Justin Stitt
2025-08-29 10:26   ` Thomas Bogendoerfer
2025-08-17 18:37 ` [PATCH 7/8] MIPS: octeon: Replace deprecated strcpy() in octeon_model_get_string_buffer() Thorsten Blum
2025-08-29 10:26   ` Thomas Bogendoerfer
2025-08-17 18:37 ` [PATCH 8/8] MIPS: generic: Replace deprecated strcpy() in ocelot_detect() Thorsten Blum
2025-08-29 10:27   ` Thomas Bogendoerfer
2025-08-18 23:24 ` [PATCH 1/8] MIPS: sgi-ip22: Replace deprecated strcpy() in plat_mem_setup() Justin Stitt
2025-08-29 10:25 ` Thomas Bogendoerfer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).