aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2024-05-17 23:55:55 +0200
committerGitHub <noreply@github.com>2024-05-17 23:55:55 +0200
commite7d871c8bf64962a658e447b90a1a3b43aaddc28 (patch)
tree7aec2a095a30ed609ce96f85ec3c4e0a8b8eb74c /src
parent497f341eac230fab13d6b5c5153c36321371b180 (diff)
parent56d5aa3101945e81519a3fac8783d0d8fad82779 (diff)
downloadafl++-e7d871c8bf64962a658e447b90a1a3b43aaddc28.tar.gz
Merge pull request #2093 from AFLplusplus/dev
push to stable
Diffstat (limited to 'src')
-rw-r--r--src/afl-cc.c10
-rw-r--r--src/afl-fuzz-run.c3
-rw-r--r--src/afl-fuzz-stats.c27
-rw-r--r--src/afl-fuzz.c9
-rw-r--r--src/afl-showmap.c15
5 files changed, 25 insertions, 39 deletions
diff --git a/src/afl-cc.c b/src/afl-cc.c
index 7acee8e4..c872b2eb 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -2794,11 +2794,11 @@ static void maybe_usage(aflcc_state_t *aflcc, int argc, char **argv) {
"MODES: NCC PERSIST DICT LAF "
"CMPLOG SELECT\n"
" [LLVM] LLVM: %s%s\n"
- " PCGUARD %s yes yes module yes yes "
+ " PCGUARD %s yes yes module yes yes "
"yes\n"
" NATIVE AVAILABLE no yes no no "
"part. yes\n"
- " CLASSIC %s no yes module yes yes "
+ " CLASSIC %s no yes module yes yes "
"yes\n"
" - NORMAL\n"
" - CALLER\n"
@@ -2815,10 +2815,10 @@ static void maybe_usage(aflcc_state_t *aflcc, int argc, char **argv) {
" [GCC/CLANG] simple gcc/clang: %s%s\n"
" CLASSIC DEFAULT no no no no no "
"no\n\n",
- aflcc->have_llvm ? "AVAILABLE" : "unavailable!",
+ aflcc->have_llvm ? "AVAILABLE " : "unavailable!",
aflcc->compiler_mode == LLVM ? " [SELECTED]" : "",
- aflcc->have_llvm ? "AVAILABLE" : "unavailable!",
- aflcc->have_llvm ? "AVAILABLE" : "unavailable!",
+ aflcc->have_llvm ? "AVAILABLE " : "unavailable!",
+ aflcc->have_llvm ? "AVAILABLE " : "unavailable!",
aflcc->have_lto ? "AVAILABLE" : "unavailable!",
aflcc->compiler_mode == LTO ? " [SELECTED]" : "",
aflcc->have_gcc_plugin ? "AVAILABLE" : "unavailable!",
diff --git a/src/afl-fuzz-run.c b/src/afl-fuzz-run.c
index 2a55da00..b62db1ea 100644
--- a/src/afl-fuzz-run.c
+++ b/src/afl-fuzz-run.c
@@ -606,6 +606,8 @@ u8 calibrate_case(afl_state_t *afl, struct queue_entry *q, u8 *use_mem,
}
q->exec_us = diff_us / afl->stage_max;
+ if (unlikely(!q->exec_us)) { q->exec_us = 1; }
+
q->bitmap_size = count_bytes(afl, afl->fsrv.trace_bits);
q->handicap = handicap;
q->cal_failed = 0;
@@ -1193,4 +1195,3 @@ common_fuzz_stuff(afl_state_t *afl, u8 *out_buf, u32 len) {
return 0;
}
-
diff --git a/src/afl-fuzz-stats.c b/src/afl-fuzz-stats.c
index 755e1c50..ffe56cde 100644
--- a/src/afl-fuzz-stats.c
+++ b/src/afl-fuzz-stats.c
@@ -321,8 +321,9 @@ void write_stats_file(afl_state_t *afl, u32 t_bytes, double bitmap_cvg,
#ifndef __HAIKU__
if (getrusage(RUSAGE_CHILDREN, &rus)) { rus.ru_maxrss = 0; }
#endif
- u64 runtime = afl->prev_run_time + cur_time - afl->start_time;
- if (!runtime) { runtime = 1; }
+ u64 runtime_ms = afl->prev_run_time + cur_time - afl->start_time;
+ u64 overhead_ms = (afl->calibration_time_us + afl->sync_time_us + afl->trim_time_us) / 1000;
+ if (!runtime_ms) { runtime_ms = 1; }
fprintf(
f,
@@ -375,20 +376,17 @@ void write_stats_file(afl_state_t *afl, u32 t_bytes, double bitmap_cvg,
"target_mode : %s%s%s%s%s%s%s%s%s%s\n"
"command_line : %s\n",
(afl->start_time /*- afl->prev_run_time*/) / 1000, cur_time / 1000,
- runtime / 1000, (u32)getpid(),
+ runtime_ms / 1000, (u32)getpid(),
afl->queue_cycle ? (afl->queue_cycle - 1) : 0, afl->cycles_wo_finds,
afl->longest_find_time > cur_time - afl->last_find_time
? afl->longest_find_time / 1000
: ((afl->start_time == 0 || afl->last_find_time == 0)
? 0
: (cur_time - afl->last_find_time) / 1000),
- (runtime -
- ((afl->calibration_time_us + afl->sync_time_us + afl->trim_time_us) /
- 1000)) /
- 1000,
+ (runtime_ms - MIN(runtime_ms, overhead_ms)) / 1000,
afl->calibration_time_us / 1000000, afl->sync_time_us / 1000000,
afl->trim_time_us / 1000000, afl->fsrv.total_execs,
- afl->fsrv.total_execs / ((double)(runtime) / 1000),
+ afl->fsrv.total_execs / ((double)(runtime_ms) / 1000),
afl->last_avg_execs_saved, afl->queued_items, afl->queued_favored,
afl->queued_discovered, afl->queued_imported, afl->queued_variable,
afl->max_depth, afl->current_entry, afl->pending_favored,
@@ -632,9 +630,9 @@ void show_stats_normal(afl_state_t *afl) {
cur_ms = get_cur_time();
- if (afl->most_time_key) {
+ if (afl->most_time_key && afl->queue_cycle) {
- if (afl->most_time * 1000 < cur_ms - afl->start_time) {
+ if (afl->most_time * 1000 + afl->sync_time_us / 1000 < cur_ms - afl->start_time) {
afl->most_time_key = 2;
afl->stop_soon = 2;
@@ -643,7 +641,7 @@ void show_stats_normal(afl_state_t *afl) {
}
- if (afl->most_execs_key == 1) {
+ if (afl->most_execs_key == 1 && afl->queue_cycle) {
if (afl->most_execs <= afl->fsrv.total_execs) {
@@ -1462,9 +1460,9 @@ void show_stats_pizza(afl_state_t *afl) {
cur_ms = get_cur_time();
- if (afl->most_time_key) {
+ if (afl->most_time_key && afl->queue_cycle) {
- if (afl->most_time * 1000 < cur_ms - afl->start_time) {
+ if (afl->most_time * 1000 + afl->sync_time_us / 1000 < cur_ms - afl->start_time) {
afl->most_time_key = 2;
afl->stop_soon = 2;
@@ -1473,7 +1471,7 @@ void show_stats_pizza(afl_state_t *afl) {
}
- if (afl->most_execs_key == 1) {
+ if (afl->most_execs_key == 1 && afl->queue_cycle) {
if (afl->most_execs <= afl->fsrv.total_execs) {
@@ -2505,4 +2503,3 @@ void update_sync_time(afl_state_t *afl, u64 *time) {
*time = cur;
}
-
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 1f0037ba..70ab983c 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -1806,7 +1806,7 @@ int main(int argc, char **argv_orig, char **envp) {
afl->fsrv.use_fauxsrv = afl->non_instrumented_mode == 1 || afl->no_forkserver;
afl->fsrv.max_length = afl->max_length;
-
+
#ifdef __linux__
if (!afl->fsrv.nyx_mode) {
@@ -2594,13 +2594,6 @@ int main(int argc, char **argv_orig, char **envp) {
sync_fuzzers(afl);
- if (!afl->queue_cycle && afl->afl_env.afl_import_first) {
-
- // real start time, we reset, so this works correctly with -V
- afl->start_time = get_cur_time();
-
- }
-
}
++afl->queue_cycle;
diff --git a/src/afl-showmap.c b/src/afl-showmap.c
index 07a4844a..7e875040 100644
--- a/src/afl-showmap.c
+++ b/src/afl-showmap.c
@@ -178,7 +178,8 @@ fsrv_run_result_t fuzz_run_target(afl_state_t *afl, afl_forkserver_t *fsrv,
void classify_counts(afl_forkserver_t *fsrv) {
u8 *mem = fsrv->trace_bits;
- const u8 *map = binary_mode ? count_class_binary : count_class_human;
+ const u8 *map = (binary_mode || collect_coverage) ? count_class_binary
+ : count_class_human;
u32 i = map_size;
@@ -240,14 +241,7 @@ static void analyze_results(afl_forkserver_t *fsrv) {
u32 i;
for (i = 0; i < map_size; i++) {
- if (fsrv->trace_bits[i]) {
-
- total += fsrv->trace_bits[i];
- if (fsrv->trace_bits[i] > highest) highest = fsrv->trace_bits[i];
- // if (!coverage_map[i]) { coverage_map[i] = 1; }
- coverage_map[i] |= fsrv->trace_bits[i];
-
- }
+ if (fsrv->trace_bits[i]) { coverage_map[i] |= fsrv->trace_bits[i]; }
}
@@ -1339,6 +1333,8 @@ int main(int argc, char **argv_orig, char **envp) {
}
+ if (collect_coverage) { binary_mode = false; } // ensure this
+
if (optind == argc || !out_file) { usage(argv[0]); }
if (in_dir && in_filelist) { FATAL("you can only specify either -i or -I"); }
@@ -1677,7 +1673,6 @@ int main(int argc, char **argv_orig, char **envp) {
if ((coverage_map = (u8 *)malloc(map_size + 64)) == NULL)
FATAL("coult not grab memory");
edges_only = false;
- raw_instr_output = true;
}