about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2019-09-19 17:56:01 +0200
committerAndrea Fioraldi <andreafioraldi@gmail.com>2019-09-19 17:56:01 +0200
commit63677bb1f963b2f6ee7157e94d471d3b1df8f162 (patch)
treeb1ac8e3271b832f7f6dad8b9e81ba7c10dd11dad
parent780a78c825d996deb768a55f4d5cbddec0f4e459 (diff)
parentc29af4aeba91bfef147573e4c232d443558af427 (diff)
downloadafl++-63677bb1f963b2f6ee7157e94d471d3b1df8f162.tar.gz
Merge branch 'master' of github.com:vanhauser-thc/AFLplusplus
-rw-r--r--src/afl-fuzz-init.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/afl-fuzz-init.c b/src/afl-fuzz-init.c
index e791fdde..4908626a 100644
--- a/src/afl-fuzz-init.c
+++ b/src/afl-fuzz-init.c
@@ -1479,9 +1479,39 @@ void check_cpu_governor(void) {
        "drop.\n",
        min / 1024, max / 1024);
 
-  FATAL("Suboptimal CPU scaling governor");
-#endif
+#else
+  u64   min = 0, max = 0;
+  size_t mlen = sizeof(min);
+  if (getenv("AFL_SKIP_CPUFREQ")) return;
+
+  ACTF("Checking CPU scaling governor...");
 
+  if (sysctlbyname("hw.cpufrequency_min", &min, &mlen, NULL, 0) == -1) {
+
+    WARNF("Could not check CPU min frequency");
+    return;
+
+  }
+
+  if (sysctlbyname("hw.cpufrequency_max", &max, &mlen, NULL, 0) == -1) {
+
+    WARNF("Could not check CPU max frequency");
+    return;
+
+  }
+
+  if (min == max) return;
+
+  SAYF("\n" cLRD "[-] " cRST
+       "Whoops, your system uses on-demand CPU frequency scaling, adjusted\n"
+       "    between %llu and %llu MHz.\n"
+       "    If you don't want to check those settings, set "
+       "AFL_SKIP_CPUFREQ\n"
+       "    to make afl-fuzz skip this check - but expect some performance "
+       "drop.\n",
+       min / 1024, max / 1024);
+#endif
+  FATAL("Suboptimal CPU scaling governor");
 }
 
 /* Count the number of logical CPU cores. */