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: 2006456 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=nJI0ucQH; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=pvbYbRDY; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=kvm-riscv-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Xj1kC5jNYz1xwF for ; Tue, 5 Nov 2024 06:29:23 +1100 (AEDT) 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=NEO8IPC2OrWGW7YidQM27mhrfzESuU3WV5Ep8tzCws0=; b=nJI0ucQHRajMgi GJ0RCX7p1F0hFDs1DlnZ/sU/sa+yc4ampBZE+MBRNJKL1aN7/FhfV4fsFFK6KD5yRxeLBbMf7HsO+ 4lY7RuDH02xBjtHKGHQoVva+RFX9peJppR3YQoE4/AQB6dkT5TcRUWOa7+hmxNsd/K/PRN40ArTQQ 148RQX0PH71SQTZqThsjzSQ0GfrIRdfXJbV+AvnuPjvxhCmJOIS/bQ2c5TsuHYaud8BgG8cm3ZpVJ spYP8QyVxSNOFxEhIJzkAmrCAM5sthrQwjRYHup1AqEwrRAe/kRUXpu+7iPVSoD2xJ0SQGhH+l6Rr kUiisuqQ0lRzJNaejmlw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t82lO-0000000Etkp-10Cf; 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-Spam-Score: -2.4 (--) X-Spam-Report: =?unknown-8bit?q?Spam_detection_software=2C_running_on_the_sy?= =?unknown-8bit?q?stem_=22bombadil=2Einfradead=2Eorg=22=2C?= =?unknown-8bit?q?_has_NOT_identified_this_incoming_email_as_spam=2E__The_ori?= =?unknown-8bit?q?ginal?= =?unknown-8bit?q?_message_has_been_attached_to_this_so_you_can_view_it_or_la?= =?unknown-8bit?q?bel?= =?unknown-8bit?q?_similar_future_email=2E__If_you_have_any_questions=2C_see?= =?unknown-8bit?q?_the_administrator_of_that_system_for_details=2E?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_preview=3A__From=3A_Bj=C3=B6rn_T=C3=B6pel_=3Cbjorn?= =?unknown-8bit?q?=40rivosinc=2Ecom=3E_The_snprintf=28=29_function?= =?unknown-8bit?q?_does_not_get_the_correct_size_argument_passed=2C_when_the_?= =?unknown-8bit?q?FDT_ISA_string_is?= =?unknown-8bit?q?_built=2E_Instead_of_adjusting_the_size_for_each_extension?= =?unknown-8bit?q?=2C_the_full_size_is?= =?unknown-8bit?q?_passed_for_every_iteration=2E_=5B=2E=2E=2E=5D_?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_Content_analysis_details=3A___=28-2=2E4_points=2C_5=2E0_re?= =?unknown-8bit?q?quired=29?= =?unknown-8bit?q?_?= =?unknown-8bit?q?_pts_rule_name______________description?= =?unknown-8bit?q?_----_----------------------_------------------------------?= =?unknown-8bit?q?--------------------?= =?unknown-8bit?q?_-0=2E0_SPF=5FPASS_______________SPF=3A_sender_matches_SPF_?= =?unknown-8bit?q?record?= =?unknown-8bit?q?_0=2E0_SPF=5FHELO=5FNONE__________SPF=3A_HELO_does_not_publ?= =?unknown-8bit?q?ish_an_SPF_Record?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FEF__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from?= =?unknown-8bit?q?_envelope-from_domain?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID=5FAU__________Message_has_a_valid_DKIM?= =?unknown-8bit?q?_or_DK_signature_from_author=27s?= =?unknown-8bit?q?_domain?= =?unknown-8bit?q?_0=2E1_DKIM=5FSIGNED____________Message_has_a_DKIM_or_DK_si?= =?unknown-8bit?q?gnature=2C_not_necessarily_valid?= =?unknown-8bit?q?_-0=2E1_DKIM=5FVALID_____________Message_has_at_least_one_v?= =?unknown-8bit?q?alid_DKIM_or_DK_signature?= =?unknown-8bit?q?_-1=2E9_BAYES=5F00_______________BODY=3A_Bayes_spam_probabi?= =?unknown-8bit?q?lity_is_0_to_1=25?= =?unknown-8bit?q?_=5Bscore=3A_0=2E0000=5D?= =?unknown-8bit?q?_0=2E0_RCVD=5FIN=5FVALIDITY=5FCERTIFIED=5FBLOCKED_RBL=3A_AD?= =?unknown-8bit?q?MINISTRATOR_NOTICE=3A_The?= =?unknown-8bit?q?_query_to_Validity_was_blocked=2E__See?= =?unknown-8bit?q?_https=3A//knowledge=2Evalidity=2Ecom/hc/en-us/articles/209?= =?unknown-8bit?q?61730681243?= =?unknown-8bit?q?_for_more_information=2E?= =?unknown-8bit?q?_=5B147=2E75=2E193=2E91_listed_in_sa-trusted=2Ebondedsender?= =?unknown-8bit?q?=2Eorg=5D?= =?unknown-8bit?q?_0=2E0_RCVD=5FIN=5FVALIDITY=5FSAFE=5FBLOCKED_RBL=3A_ADMINIS?= =?unknown-8bit?q?TRATOR_NOTICE=3A_The_query_to?= =?unknown-8bit?q?_Validity_was_blocked=2E__See?= =?unknown-8bit?q?_https=3A//knowledge=2Evalidity=2Ecom/hc/en-us/articles/209?= =?unknown-8bit?q?61730681243?= =?unknown-8bit?q?_for_more_information=2E?= =?unknown-8bit?q?_=5B147=2E75=2E193=2E91_listed_in_sa-accredit=2Ehabeas=2Eco?= =?unknown-8bit?q?m=5D?= =?unknown-8bit?q?_-0=2E3_DKIMWL=5FWL=5FHIGH_________DKIMwl=2Eorg_-_High_trus?= =?unknown-8bit?q?t_sender?= =?unknown-8bit?q?_0=2E0_RCVD=5FIN=5FVALIDITY=5FRPBL=5FBLOCKED_RBL=3A_ADMINIS?= =?unknown-8bit?q?TRATOR_NOTICE=3A_The_query_to?= =?unknown-8bit?q?_Validity_was_blocked=2E__See?= =?unknown-8bit?q?_https=3A//knowledge=2Evalidity=2Ecom/hc/en-us/articles/209?= =?unknown-8bit?q?61730681243?= =?unknown-8bit?q?_for_more_information=2E?= =?unknown-8bit?q?_=5B147=2E75=2E193=2E91_listed_in_bl=2Escore=2Esenderscore?= =?unknown-8bit?q?=2Ecom=5D?= X-BeenThere: kvm-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: "kvm-riscv" Errors-To: kvm-riscv-bounces+incoming=patchwork.ozlabs.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';