From patchwork Mon Nov 4 19:21:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= X-Patchwork-Id: 13861893 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 81878D1BDE7 for ; Mon, 4 Nov 2024 19:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Nc6luj5grDNcoiPTrxPeNLh+BsxqNvYD2KEVwu0LB/Y=; b=CshEGtTQpNAlJj PCuBq5BoSwk0gsvTJU2Oy90jceVSmg7l1FVv2X92un8YB4AVwmAXM0bUdA/t3iX+UIUR9XpkB7X0g J8zAt/ZgqeipRMe5+q9532/SRybjpG5LNtLfDdP2Fiy/ZeNh6MX9W3kks4GGa/p75PFsjMJMYTAdM 9dWNHWnSpktokRMxr6LWz9yBGuns0FFiTJbKhaanYDkv0Ox07xYPbJY/h8AUnHIMXqn/8oUCLgGsZ e8ZZ2pTkRxVA6BGRlgHvjmQlkK4PtFCPhL0Wr2inJbeWu0G5Ge/wGEnH4/Kkel4czTIkw1eX2rws8 xQEBu0KzELZNbQ6hoOWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t82lO-0000000EtlR-46Vn; Mon, 04 Nov 2024 19:29:22 +0000 Received: from nyc.source.kernel.org ([147.75.193.91]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t82dl-0000000Esn7-47Ej; Mon, 04 Nov 2024 19:21:31 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id ED906A43357; Mon, 4 Nov 2024 19:19:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF103C4CECE; Mon, 4 Nov 2024 19:21:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1730748088; bh=srsnEmNy8EqgMWWSao2qd7ZIE1/ia9oFgHAob0jN4H0=; h=From:To:Cc:Subject:Date:From; b=pvbYbRDYTVEtjkRIfobR7lI+Lm0UsV7fRe5dpaxwKiy7kgbsn0ZAwDe/XWxTT/4/N 8qr405SaAlQwnh5gYtSTw8kbgAWU3EZeNTvV2LQDvZkcppMCyaFOsg+bib37lH+ahU wvhKtmGeSSgzrSG+G26Z0ADcuKkZCGpHtdj8DGmJHas5Ly01H3VIglgN1QfKGZElnF BEXlwydzHJYTgA2ucPLTwyIC05Drz/ZV7vYvDAtfCFoSDjj6ETBX+if2yc4CF1Hukg GDW5czFAZu90rmOewRpVmGTXcmn6HTRufTV2DBQfpwIAmVNtxuv9o4KH+8ssVoHCsr B12eapXcbatLw== From: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= To: Will Deacon , Julien Thierry , Anup Patel , kvm@vger.kernel.org, kvm-riscv@lists.infradead.org Cc: =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Andrew Jones , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH kvmtool] riscv: Pass correct size to snprintf() Date: Mon, 4 Nov 2024 20:21:19 +0100 Message-ID: <20241104192120.75841-1-bjorn@kernel.org> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241104_112130_108221_B8AC23C1 X-CRM114-Status: GOOD ( 10.70 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Björn Töpel The snprintf() function does not get the correct size argument passed, when the FDT ISA string is built. Instead of adjusting the size for each extension, the full size is passed for every iteration. Doing so will make __snprinf_chk() bail out on glibc. Adjust size for each iteration. Fixes: 8aff29e1dafe ("riscv: Append ISA extensions to the device tree") Signed-off-by: Björn Töpel Reviewed-by: Andrew Jones --- riscv/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) base-commit: 3040b298156e4e2a82b27ac8db5bd63a72b3785b diff --git a/riscv/fdt.c b/riscv/fdt.c index 8189601f46de..85c8f95604f6 100644 --- a/riscv/fdt.c +++ b/riscv/fdt.c @@ -157,7 +157,7 @@ static void generate_cpu_nodes(void *fdt, struct kvm *kvm) isa_info_arr[i].name); break; } - pos += snprintf(cpu_isa + pos, CPU_ISA_MAX_LEN, "_%s", + pos += snprintf(cpu_isa + pos, CPU_ISA_MAX_LEN - pos, "_%s", isa_info_arr[i].name); } cpu_isa[pos] = '\0';