Re: [PATCH 7/8] MIPS: malta-init: bound default console command-line append
From: Sergey Shtylyov
Date: Sun Apr 05 2026 - 12:08:54 EST
On 4/4/26 5:06 PM, Pengpeng Hou wrote:
> console_config() appends a synthesized console= option to fw_getcmdline()
> with unchecked strcat() when the firmware command line does not already
> provide one. If the existing command line is near full, that append can
> overflow the fixed command-line buffer.
>
> Switch the default console append to bounded concatenation.
>
> Signed-off-by: Pengpeng Hou <pengpeng@xxxxxxxxxxx>
> ---
> arch/mips/mti-malta/malta-init.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/arch/mips/mti-malta/malta-init.c b/arch/mips/mti-malta/malta-init.c
> index 82b0fd8576a2..fb782b1a3f6e 100644
> --- a/arch/mips/mti-malta/malta-init.c
> +++ b/arch/mips/mti-malta/malta-init.c
> @@ -78,13 +78,14 @@ static void __init console_config(void)
> setup_earlycon(console_string);
> }
>
> - if ((strstr(fw_getcmdline(), "console=")) == NULL) {
> - sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
> - parity, bits, flow);
> - strcat(fw_getcmdline(), console_string);
> - pr_info("Config serial console:%s\n", console_string);
> + if ((strstr(fw_getcmdline(), "console=")) == NULL) {
> + sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
> + parity, bits, flow);
I don't quit understand what changed in the above 3 lines...
> + strlcat(fw_getcmdline(), console_string,
> + COMMAND_LINE_SIZE);
> + pr_info("Config serial console:%s\n", console_string);
> + }
> }
> -}
Huh? :-)
> #endif
MBR, Sergey