public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] riscv: Fix an off-by-one in get_early_cmdline()
@ 2023-10-29  7:20 Christophe JAILLET
  2024-01-10  6:38 ` Alexandre Ghiti
  2024-01-12  6:30 ` patchwork-bot+linux-riscv
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2023-10-29  7:20 UTC (permalink / raw)
  To: Paul Walmsley, Palmer Dabbelt, Albert Ou, Alexandre Ghiti,
	Björn Töpel
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Palmer Dabbelt,
	linux-riscv

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: 26e7aacb83df ("riscv: Allow to downgrade paging mode from the command line")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 arch/riscv/kernel/pi/cmdline_early.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/riscv/kernel/pi/cmdline_early.c b/arch/riscv/kernel/pi/cmdline_early.c
index 68e786c84c94..f6d4dedffb84 100644
--- a/arch/riscv/kernel/pi/cmdline_early.c
+++ b/arch/riscv/kernel/pi/cmdline_early.c
@@ -38,8 +38,7 @@ static char *get_early_cmdline(uintptr_t dtb_pa)
 	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
 	    IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
 	    fdt_cmdline_size == 0 /* CONFIG_CMDLINE_FALLBACK */) {
-		strncat(early_cmdline, CONFIG_CMDLINE,
-			COMMAND_LINE_SIZE - fdt_cmdline_size);
+		strlcat(early_cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
 	}
 
 	return early_cmdline;
-- 
2.34.1


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: Fix an off-by-one in get_early_cmdline()
  2023-10-29  7:20 [PATCH] riscv: Fix an off-by-one in get_early_cmdline() Christophe JAILLET
@ 2024-01-10  6:38 ` Alexandre Ghiti
  2024-01-12  6:30 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Ghiti @ 2024-01-10  6:38 UTC (permalink / raw)
  To: Christophe JAILLET, Paul Walmsley, Palmer Dabbelt, Albert Ou,
	Alexandre Ghiti, Björn Töpel
  Cc: linux-kernel, kernel-janitors, Palmer Dabbelt, linux-riscv

Hi Christophe,

On 29/10/2023 08:20, Christophe JAILLET wrote:
> 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: 26e7aacb83df ("riscv: Allow to downgrade paging mode from the command line")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>   arch/riscv/kernel/pi/cmdline_early.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/arch/riscv/kernel/pi/cmdline_early.c b/arch/riscv/kernel/pi/cmdline_early.c
> index 68e786c84c94..f6d4dedffb84 100644
> --- a/arch/riscv/kernel/pi/cmdline_early.c
> +++ b/arch/riscv/kernel/pi/cmdline_early.c
> @@ -38,8 +38,7 @@ static char *get_early_cmdline(uintptr_t dtb_pa)
>   	if (IS_ENABLED(CONFIG_CMDLINE_EXTEND) ||
>   	    IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
>   	    fdt_cmdline_size == 0 /* CONFIG_CMDLINE_FALLBACK */) {
> -		strncat(early_cmdline, CONFIG_CMDLINE,
> -			COMMAND_LINE_SIZE - fdt_cmdline_size);
> +		strlcat(early_cmdline, CONFIG_CMDLINE, COMMAND_LINE_SIZE);
>   	}
>   
>   	return early_cmdline;

This looks good to me, you can add:

Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks,

Alex


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

* Re: [PATCH] riscv: Fix an off-by-one in get_early_cmdline()
  2023-10-29  7:20 [PATCH] riscv: Fix an off-by-one in get_early_cmdline() Christophe JAILLET
  2024-01-10  6:38 ` Alexandre Ghiti
@ 2024-01-12  6:30 ` patchwork-bot+linux-riscv
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+linux-riscv @ 2024-01-12  6:30 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: linux-riscv, paul.walmsley, palmer, aou, alexghiti, bjorn,
	linux-kernel, kernel-janitors, palmer

Hello:

This patch was applied to riscv/linux.git (for-next)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Sun, 29 Oct 2023 08:20:40 +0100 you wrote:
> 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: 26e7aacb83df ("riscv: Allow to downgrade paging mode from the command line")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> 
> [...]

Here is the summary with links:
  - riscv: Fix an off-by-one in get_early_cmdline()
    https://git.kernel.org/riscv/c/adb1f95d388a

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

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

end of thread, other threads:[~2024-01-12  6:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-29  7:20 [PATCH] riscv: Fix an off-by-one in get_early_cmdline() Christophe JAILLET
2024-01-10  6:38 ` Alexandre Ghiti
2024-01-12  6:30 ` patchwork-bot+linux-riscv

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox