Skip to content

Commit adb1f95

Browse files
tititiou36palmer-dabbelt
authored andcommitted
riscv: Fix an off-by-one in get_early_cmdline()
The ending NULL is not taken into account by strncat(), so switch to strlcat() to correctly compute the size of the available memory when appending CONFIG_CMDLINE to 'early_cmdline'. Fixes: 26e7aac ("riscv: Allow to downgrade paging mode from the command line") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com> Link: https://lore.kernel.org/r/9f66d2b58c8052d4055e90b8477ee55d9a0914f9.1698564026.git.christophe.jaillet@wanadoo.fr Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 9b1d9ab commit adb1f95

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/riscv/kernel/pi/cmdline_early.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ static char *get_early_cmdline(uintptr_t dtb_pa)
3838
if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
3939
IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
4040
fdt_cmdline_size == 0 /* CONFIG_CMDLINE_FALLBACK */) {
41-
strncat(early_cmdline, CONFIG_CMDLINE,
42-
COMMAND_LINE_SIZE - fdt_cmdline_size);
41+
strlcat(early_cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
4342
}
4443

4544
return early_cmdline;

0 commit comments

Comments
 (0)