From nobody Tue Apr 7 21:45:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1773241940; cv=none; d=zohomail.com; s=zohoarc; b=iyw9fvzirBfl0DmGOdkl09+txMtu1GlzErs/drtCCGact1YoTgtiOxZa1dbisVYxyS0Ku9CEQx+I6nQ8qllr30a0urAkKvBIopS+s/y7yHy0KX7JPnr2hQ93SVeUtLc/ASUr3T//AfJoNVmsVTcW+zzKk08A6TECX5/LLab33WQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773241940; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Rq0QLobwwzhc6KsCt7U0KM3311LFEJkCaKJbPg2yi/w=; b=HKJlS1q4AiAygBx8MzW37RZk6rC2VXydyPFP1llBzXOP7BJ3H06KzFZRTAHyGsM1dMQm4NYdvPDWAFODRGafZEvfdwWaCdNDx9+fHJjDYofCpF86ezscyoOoJw0DYg6agl0Um80s3sGZnVNN3oXmBSyRzoj6Z4To/Q+MG1TYaVc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773241940597728.5957606290634; Wed, 11 Mar 2026 08:12:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w0LBr-0001ep-AE; Wed, 11 Mar 2026 11:09:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0L9n-0004K4-1E; Wed, 11 Mar 2026 11:07:38 -0400 Received: from isrv.corpit.ru ([212.248.84.144]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w0L9h-0004yi-BD; Wed, 11 Mar 2026 11:07:28 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 6A991191E8A; Wed, 11 Mar 2026 18:04:41 +0300 (MSK) Received: from think4mjt.tls.msk.ru (mjtthink.wg.tls.msk.ru [192.168.177.146]) by tsrv.corpit.ru (Postfix) with ESMTP id 5908037C2CB; Wed, 11 Mar 2026 18:05:19 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tls.msk.ru; s=202602; t=1773241481; bh=cfcf1z7/JpS4xZDWqSxPZgHSdgbv846o0KdJ0aeJQi0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=xQsHag3kE+tM2lPWDMVEEGCAj2lBiGRGQt7cSK/XTSk/FQltHFLu9daQGbU2cOvCv RwmO/BDEhm5tk6csbKQ8MLLOWBF0B4RQwgG3L+DZ9UVSxb8fc5AlPcNvZzD4A4Akdt o/DmxPItlyRnmNUG84O4uWj8rNp/j3N1mSg8EoHuD5Z34Szc9/9Mr73vDHUYqIIzos 3kEP3s/xPoc2Fgan8kxBoo/gZnbCARQNprhJub+nIerAme7m7omOzsjVtnxez5SNyS 3+RMvukV5cfDWx3n3C6eq2tpHo4WS/sr3BXccZWMkoLB2SKY6RLrjtHFUMNrGkGYdc 2593zJIKnZkmA== From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Alex Bradbury , Pierrick Bouvier , Michael Tokarev Subject: [Stable-10.1.5 07/46] contrib/plugins/hotblocks: Fix off by one error in iteration of sorted blocks Date: Wed, 11 Mar 2026 18:02:43 +0300 Message-ID: <20260311150327.1084669-7-mjt@tls.msk.ru> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=212.248.84.144; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -2 X-Spam_score: -0.3 X-Spam_bar: / X-Spam_report: (-0.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @tls.msk.ru) X-ZM-MESSAGEID: 1773241940927158500 Content-Type: text/plain; charset="utf-8" From: Alex Bradbury The logic to iterate over the hottest blocks will never reach the last item in the list, as it checks `it->next !=3D NULL` before entering the loop. It's hard to trigger this off-by-one error with the default limit=3D20, but it is a bug and is problematic if that default is changed to something larger. Signed-off-by: Alex Bradbury Reviewed-by: Pierrick Bouvier Link: https://lore.kernel.org/qemu-devel/f1ba2e57c6126472c0c8310774009f2455= efc370.1753857212.git.asb@igalia.com Signed-off-by: Pierrick Bouvier (cherry picked from commit 1c1e45fcd66269f8a6dbd97fd7b8267d8f6f58af) Signed-off-by: Michael Tokarev diff --git a/contrib/plugins/hotblocks.c b/contrib/plugins/hotblocks.c index d3dd23ed9f..cf4d6b8c36 100644 --- a/contrib/plugins/hotblocks.c +++ b/contrib/plugins/hotblocks.c @@ -82,10 +82,9 @@ static void plugin_exit(qemu_plugin_id_t id, void *p) sorted_counts =3D g_list_sort_with_data(counts, cmp_exec_count, NULL); =20 if (sorted_counts) { - it =3D sorted_counts; g_string_append_printf(report, "pc, tcount, icount, ecount\n"); =20 - for (i =3D 0; i < limit && it->next; i++, it =3D it->next) { + for (i =3D 0, it =3D sorted_counts; i < limit && it; i++, it =3D i= t->next) { ExecCount *rec =3D (ExecCount *) it->data; g_string_append_printf( report, "0x%016"PRIx64", %d, %ld, %"PRId64"\n", --=20 2.47.3