lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251118155813.533424-3-darcari@redhat.com>
Date: Tue, 18 Nov 2025 10:58:12 -0500
From: David Arcari <darcari@...hat.com>
To: lenb@...nel.org
Cc: linux-pm@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	David Arcari <darcari@...hat.com>
Subject: [PATCH 2/3] tools/power turbostat: avoid an infinite loop of restarts

There are some error cases where turbostat will attempt to reinitialize
by calling the re_initialize() function.  The code attempts to avoid
an infinite loop by checking the value of 'restarted' in one case, but
not others. It should be checked in all cases of restart.  Additonally,
the 'restarted' is reset to zero at the start of the loop which also
needs to be removed.

Signed-off-by: David Arcari <darcari@...hat.com>
Cc: Len Brown <lenb@...nel.org>
Cc: linux-kernel@...r.kernel.org
---
 tools/power/x86/turbostat/turbostat.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 584b0f7f9067..5567b9ecd516 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -6722,7 +6722,11 @@ void turbostat_loop()
 	set_my_sched_priority(-20);
 
 restart:
-	restarted++;
+	if (restarted++ > 10) {
+		if (!retval)
+			retval = -1;
+		exit(retval);
+	}
 
 	snapshot_proc_sysfs_files();
 	retval = for_all_cpus(get_counters, EVEN_COUNTERS);
@@ -6730,13 +6734,9 @@ void turbostat_loop()
 	if (retval < -1) {
 		exit(retval);
 	} else if (retval == -1) {
-		if (restarted > 10) {
-			exit(retval);
-		}
 		re_initialize();
 		goto restart;
 	}
-	restarted = 0;
 	done_iters = 0;
 	gettimeofday(&tv_even, (struct timezone *)NULL);
 
-- 
2.51.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ