From: Pengpeng Hou <pengpeng@iscas.ac.cn>
To: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
"Maciej W. Rozycki" <macro@orcam.me.uk>
Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org,
pengpeng@iscas.ac.cn
Subject: [PATCH 4/8] MIPS: txx9: bound command-line reconstruction
Date: Sat, 4 Apr 2026 22:06:17 +0800 [thread overview]
Message-ID: <20260405102004.4-mips-cmdline-pengpeng@iscas.ac.cn> (raw)
In-Reply-To: <20260405102000.0-mips-cmdline-series-pengpeng@iscas.ac.cn>
The early txx9 command-line builders rebuild arcs_cmdline with repeated
strcat() calls when quoting PROM arguments and when reinserting filtered
arguments after preprocessing. Those append chains do not track the
remaining space in the fixed command-line buffer.
Convert the rebuild steps to bounded concatenation so long firmware
arguments cannot overflow arcs_cmdline.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
---
arch/mips/txx9/generic/setup.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/arch/mips/txx9/generic/setup.c b/arch/mips/txx9/generic/setup.c
index 6c5025806914..715059d5101e 100644
--- a/arch/mips/txx9/generic/setup.c
+++ b/arch/mips/txx9/generic/setup.c
@@ -128,13 +128,13 @@ static void __init prom_init_cmdline(void)
for (i = 1; i < argc; i++) {
char *str = (char *)(long)argv32[i];
if (i != 1)
- strcat(arcs_cmdline, " ");
+ strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
if (strchr(str, ' ')) {
- strcat(arcs_cmdline, "\"");
- strcat(arcs_cmdline, str);
- strcat(arcs_cmdline, "\"");
+ strlcat(arcs_cmdline, "\"", COMMAND_LINE_SIZE);
+ strlcat(arcs_cmdline, str, COMMAND_LINE_SIZE);
+ strlcat(arcs_cmdline, "\"", COMMAND_LINE_SIZE);
} else
- strcat(arcs_cmdline, str);
+ strlcat(arcs_cmdline, str, COMMAND_LINE_SIZE);
}
}
@@ -227,8 +227,8 @@ static void __init preprocess_cmdline(void)
continue;
}
if (arcs_cmdline[0])
- strcat(arcs_cmdline, " ");
- strcat(arcs_cmdline, str);
+ strlcat(arcs_cmdline, " ", COMMAND_LINE_SIZE);
+ strlcat(arcs_cmdline, str, COMMAND_LINE_SIZE);
}
txx9_cache_fixup();
--
2.50.1 (Apple Git-155)
next prev parent reply other threads:[~2026-04-05 2:32 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-05 2:20 [PATCH 0/8] MIPS: bound early command-line construction Pengpeng Hou
2026-04-04 14:06 ` [PATCH 3/8] MIPS: lemote-2f: bound machtype command-line append Pengpeng Hou
2026-04-04 14:06 ` [PATCH 1/8] MIPS: dec: bound PROM command-line appends Pengpeng Hou
2026-04-04 14:06 ` [PATCH 2/8] MIPS: sni: " Pengpeng Hou
2026-04-04 14:06 ` [PATCH 5/8] MIPS: arc: bound firmware command-line construction Pengpeng Hou
2026-04-04 14:06 ` [PATCH 8/8] MIPS: malta-setup: bound pci_clock command-line append Pengpeng Hou
2026-04-04 14:06 ` Pengpeng Hou [this message]
2026-04-04 14:06 ` [PATCH 7/8] MIPS: malta-init: bound default console " Pengpeng Hou
2026-04-05 16:08 ` Sergey Shtylyov
2026-04-06 5:30 ` Pengpeng Hou
2026-04-04 14:06 ` [PATCH 6/8] MIPS: cavium-octeon: " Pengpeng Hou
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260405102004.4-mips-cmdline-pengpeng@iscas.ac.cn \
--to=pengpeng@iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=tsbogend@alpha.franken.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®