[PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()

Thorsten Blum posted 1 patch 9 months, 3 weeks ago
arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Thorsten Blum 9 months, 3 weeks ago
strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
index 9cc8fbf218a5..c5617b889b1c 100644
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -764,7 +764,7 @@ void __init board_prom_init(void)
 			snprintf(cfe_version, 12, "%s", (char *) &cfe[4]);
 		}
 	} else {
-		strcpy(cfe_version, "unknown");
+		strscpy(cfe_version, "unknown");
 	}
 	pr_info("CFE version: %s\n", cfe_version);
 
-- 
2.49.0
Re: [PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Thomas Bogendoerfer 9 months, 2 weeks ago
On Tue, Apr 22, 2025 at 09:42:55AM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.
> 
> Link: https://github.com/KSPP/linux/issues/88
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
>  arch/mips/bcm63xx/boards/board_bcm963xx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/mips/bcm63xx/boards/board_bcm963xx.c b/arch/mips/bcm63xx/boards/board_bcm963xx.c
> index 9cc8fbf218a5..c5617b889b1c 100644
> --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
> +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
> @@ -764,7 +764,7 @@ void __init board_prom_init(void)
>  			snprintf(cfe_version, 12, "%s", (char *) &cfe[4]);
>  		}
>  	} else {
> -		strcpy(cfe_version, "unknown");
> +		strscpy(cfe_version, "unknown");
>  	}
>  	pr_info("CFE version: %s\n", cfe_version);
>  
> -- 
> 2.49.0

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 ]
Re: [PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Andy Shevchenko 9 months, 3 weeks ago
On Tue, Apr 22, 2025 at 09:42:55AM +0200, Thorsten Blum wrote:
> strcpy() is deprecated; use strscpy() instead.

> Link: https://github.com/KSPP/linux/issues/88

> Cc: linux-hardening@vger.kernel.org

Can you use --cc OR put this line...

> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---

...here (after the cutter), so we won't see this in the commit message? The
list will be available in the lore archive anyway.

> @@ -764,7 +764,7 @@ void __init board_prom_init(void)
>  			snprintf(cfe_version, 12, "%s", (char *) &cfe[4]);
>  		}
>  	} else {
> -		strcpy(cfe_version, "unknown");
> +		strscpy(cfe_version, "unknown");
>  	}

Have you compiled this with `make W=1` with recent GCCs? I would recommend to
rewrite the whole function, as per commit ee44a1def7ee ("leds: core: Bail out
when composed name can't fit the buffer") in Linux Next.

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Thorsten Blum 9 months, 3 weeks ago
Hi Andy,

On 22. Apr 2025, at 10:03, Andy Shevchenko wrote:

> Can you use --cc OR put this line...

Yes, will do next time.

> Have you compiled this with `make W=1` with recent GCCs?

Yes, I compile-tested it with W=1 and mips64-linux-gnu-gcc 14.2.1.

Thanks,
Thorsten
Re: [PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Andy Shevchenko 9 months, 3 weeks ago
On Tue, Apr 22, 2025 at 10:27:33AM +0200, Thorsten Blum wrote:
> On 22. Apr 2025, at 10:03, Andy Shevchenko wrote:
> > Can you use --cc OR put this line...
> 
> Yes, will do next time.
> 
> > Have you compiled this with `make W=1` with recent GCCs?
> 
> Yes, I compile-tested it with W=1 and mips64-linux-gnu-gcc 14.2.1.

Cool, no warnings?

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Thorsten Blum 9 months, 3 weeks ago
On 22. Apr 2025, at 12:17, Andy Shevchenko wrote:
> On Tue, Apr 22, 2025 at 10:27:33AM +0200, Thorsten Blum wrote:
>> On 22. Apr 2025, at 10:03, Andy Shevchenko wrote:
>>> Can you use --cc OR put this line...
>> 
>> Yes, will do next time.
>> 
>>> Have you compiled this with `make W=1` with recent GCCs?
>> 
>> Yes, I compile-tested it with W=1 and mips64-linux-gnu-gcc 14.2.1.
> 
> Cool, no warnings?

No warnings, at least none related to my change or compiling
board_bcm963xx.c

Best,
Thorsten
Re: [PATCH] MIPS: BCM63XX: Replace strcpy() with strscpy() in board_prom_init()
Posted by Andy Shevchenko 9 months, 2 weeks ago
On Tue, Apr 22, 2025 at 12:33:48PM +0200, Thorsten Blum wrote:
> On 22. Apr 2025, at 12:17, Andy Shevchenko wrote:
> > On Tue, Apr 22, 2025 at 10:27:33AM +0200, Thorsten Blum wrote:
> >> On 22. Apr 2025, at 10:03, Andy Shevchenko wrote:
> >>> Can you use --cc OR put this line...
> >> 
> >> Yes, will do next time.
> >> 
> >>> Have you compiled this with `make W=1` with recent GCCs?
> >> 
> >> Yes, I compile-tested it with W=1 and mips64-linux-gnu-gcc 14.2.1.
> > 
> > Cool, no warnings?
> 
> No warnings, at least none related to my change or compiling
> board_bcm963xx.c

Thanks for confirming!

-- 
With Best Regards,
Andy Shevchenko