Skip to content

Commit bb07972

Browse files
azeemshaikh38kees
authored andcommitted
sparc64: Replace all non-returning strlcpy with strscpy
strlcpy() reads the entire source buffer first. This read may exceed the destination size limit. This is both inefficient and can lead to linear read overflows if a source string is not NUL-terminated [1]. In an effort to remove strlcpy() completely [2], replace strlcpy() here with strscpy(). No return values were used, so direct replacement is safe. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy [2] KSPP#89 Signed-off-by: Azeem Shaikh <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f0e212d commit bb07972

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

arch/sparc/kernel/ioport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static void __iomem *_sparc_alloc_io(unsigned int busno, unsigned long phys,
191191
tack += sizeof (struct resource);
192192
}
193193

194-
strlcpy(tack, name, XNMLN+1);
194+
strscpy(tack, name, XNMLN+1);
195195
res->name = tack;
196196

197197
va = _sparc_ioremap(res, busno, phys, size);

arch/sparc/kernel/setup_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void __init setup_arch(char **cmdline_p)
302302

303303
/* Initialize PROM console and command line. */
304304
*cmdline_p = prom_getbootargs();
305-
strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
305+
strscpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
306306
parse_early_param();
307307

308308
boot_flags_init(*cmdline_p);

arch/sparc/kernel/setup_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ void __init setup_arch(char **cmdline_p)
636636
{
637637
/* Initialize PROM console and command line. */
638638
*cmdline_p = prom_getbootargs();
639-
strlcpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
639+
strscpy(boot_command_line, *cmdline_p, COMMAND_LINE_SIZE);
640640
parse_early_param();
641641

642642
boot_flags_init(*cmdline_p);

arch/sparc/prom/bootstr_32.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ prom_getbootargs(void)
5252
* V3 PROM cannot supply as with more than 128 bytes
5353
* of an argument. But a smart bootstrap loader can.
5454
*/
55-
strlcpy(barg_buf, *romvec->pv_v2bootargs.bootargs, sizeof(barg_buf));
55+
strscpy(barg_buf, *romvec->pv_v2bootargs.bootargs, sizeof(barg_buf));
5656
break;
5757
default:
5858
break;

0 commit comments

Comments
 (0)