From nobody Thu Jun 18 08:02:42 2026 Received: from cstnet.cn (smtp25.cstnet.cn [159.226.251.25]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39EE432AADE for ; Fri, 17 Apr 2026 07:42:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.25 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776411755; cv=none; b=tLjoQo3q+7tReB4/WdqG/ZUaa/HoQVAQOmDnnqFsxDIhL49Y1HW8HEgVVM5LEXxdV4cnWsKXR0cETXLurHSCHhdOtQbS3dQicTy2QeLqaFWQMkw4zV3lTufzGx0kIwXt52XIaEsax5iAEQzBfqAnohjU1v6f9dc1qq4EIbSMOP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776411755; c=relaxed/simple; bh=4NoCafye0uRw3M1Mkhp7Cep4FDwxZeud6y2CN/OdLVk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=jeuuBRKjv5kZh2LycHK7+qyAZ8GFmduvZTqIqNzBhWndGnx9F9mFD9L0akmaVeUZ+/FI6HD8NOloilVLSnm4DGkkXAKfc9sDIimNN2Cpth/pOpPcAytNGEkK5Wx13L4PBqEW6u0GvCQ+GDld6bW1BaJ8cQ+XAgue2B/yiKHlMGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn; spf=pass smtp.mailfrom=iscas.ac.cn; arc=none smtp.client-ip=159.226.251.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=iscas.ac.cn Received: from localhost.localdomain (unknown [111.196.245.116]) by APP-05 (Coremail) with SMTP id zQCowACnOw9l5OFptxDYDQ--.18801S2; Fri, 17 Apr 2026 15:42:29 +0800 (CST) From: Pengpeng Hou To: Chris Zankel , Max Filippov Cc: linux-kernel@vger.kernel.org, Pengpeng Hou Subject: [PATCH] xtensa: iss: bound command line construction in platform_setup() Date: Fri, 17 Apr 2026 15:42:26 +0800 Message-ID: <20260417074226.9295-1-pengpeng@iscas.ac.cn> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: zQCowACnOw9l5OFptxDYDQ--.18801S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CFyrtF1xWw18tw4UJw13Arb_yoW8XryUpF yjkws3Jr4kGw47t347XF1rurWrZ3Z3tw17Ar4Igw1xu3Z5Xry7Wr4FgF1rX34DXr1xuayU Xr9FkrW8CFyav3DanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyC14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26F1j6w1UM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1l42xK82IYc2Ij64vI r41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8Gjc xK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2Ix0 cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26F4j6r4UJwCI42IY6xAIw2 0EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Gr0_Cr1lIxAIcVC2z280aVCY1x02 67AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUsiSdUUUUU= X-CM-SenderInfo: pshqw1xhqjqxpvfd2hldfou0/ Content-Type: text/plain; charset="utf-8" platform_setup() concatenates simulator arguments into the fixed COMMAND_LINE_SIZE cmdline buffer with raw strcat() appends. The code only checks the size of the argv pointer block that simc_argv() fills, not the final length of the concatenated command line string, so a long enough argument list can write past the end of cmdline. Build the command line with scnprintf() and stop once the fixed buffer is full. Fixes: b26d0ab0e6fa ("[XTENSA] Concentrate platforms into one platforms dir= ectory.") Signed-off-by: Pengpeng Hou --- arch/xtensa/platforms/iss/setup.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/xtensa/platforms/iss/setup.c b/arch/xtensa/platforms/iss/= setup.c index 0f1fe132691e..9bc7f21c9a0c 100644 --- a/arch/xtensa/platforms/iss/setup.c +++ b/arch/xtensa/platforms/iss/setup.c @@ -69,15 +69,21 @@ void __init platform_setup(char **p_cmdline) pr_err("%s: command line too long: argv_size =3D %d\n", __func__, argv_size); } else { - int i; + int i, len =3D 0; =20 cmdline[0] =3D 0; simc_argv((void *)argv); =20 for (i =3D 1; i < argc; ++i) { - if (i > 1) - strcat(cmdline, " "); - strcat(cmdline, argv[i]); + len +=3D scnprintf(cmdline + len, + COMMAND_LINE_SIZE - len, + "%s%s", i > 1 ? " " : "", + argv[i]); + if (len >=3D COMMAND_LINE_SIZE - 1) { + pr_err("%s: command line too long\n", + __func__); + break; + } } *p_cmdline =3D cmdline; } --=20 2.50.1 (Apple Git-155)