mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-16 03:48:08 +00:00
Merge pull request #1667 from amitelka/feature/opt_statsfile_update_interval
Added env variable to allow custom interval update of fuzzer_stats file
This commit is contained in:
@ -584,6 +584,12 @@ checks or alter some of the more exotic semantics of the tool:
|
||||
- Set `AFL_PIZZA_MODE` to 1 to enable the April 1st stats menu, set to 0
|
||||
to disable although it is 1st of April.
|
||||
|
||||
- If you need a specific interval to update fuzzer_stats file, you can
|
||||
set `AFL_FUZZER_STATS_UPDATE_INTERVAL` to the interval in seconds you'd
|
||||
the file to be updated.
|
||||
Note that will not be exact and with slow targets it can take seconds
|
||||
until there is a slice for the time test.
|
||||
|
||||
## 5) Settings for afl-qemu-trace
|
||||
|
||||
The QEMU wrapper used to instrument binary-only code supports several settings:
|
||||
|
@ -693,6 +693,7 @@ typedef struct afl_state {
|
||||
|
||||
/* statistics file */
|
||||
double last_bitmap_cvg, last_stability, last_eps;
|
||||
u64 stats_file_update_freq_msecs; /* Stats update frequency (msecs) */
|
||||
|
||||
/* plot file saves from last run */
|
||||
u32 plot_prev_qp, plot_prev_pf, plot_prev_pnf, plot_prev_ce, plot_prev_md;
|
||||
|
@ -91,6 +91,7 @@ static char *afl_environment_variables[] = {
|
||||
"AFL_FRIDA_TRACEABLE",
|
||||
"AFL_FRIDA_VERBOSE",
|
||||
"AFL_FUZZER_ARGS", // oss-fuzz
|
||||
"AFL_FUZZER_STATS_UPDATE_INTERVAL",
|
||||
"AFL_GDB",
|
||||
"AFL_GCC_ALLOWLIST",
|
||||
"AFL_GCC_DENYLIST",
|
||||
|
@ -24,6 +24,7 @@
|
||||
*/
|
||||
|
||||
#include <signal.h>
|
||||
#include <limits.h>
|
||||
#include "afl-fuzz.h"
|
||||
#include "envs.h"
|
||||
|
||||
@ -100,6 +101,7 @@ void afl_state_init(afl_state_t *afl, uint32_t map_size) {
|
||||
afl->hang_tmout = EXEC_TIMEOUT;
|
||||
afl->exit_on_time = 0;
|
||||
afl->stats_update_freq = 1;
|
||||
afl->stats_file_update_freq_msecs = STATS_UPDATE_SEC * 1000;
|
||||
afl->stats_avg_exec = 0;
|
||||
afl->skip_deterministic = 1;
|
||||
afl->sync_time = SYNC_TIME;
|
||||
@ -565,6 +567,26 @@ void read_afl_environment(afl_state_t *afl, char **envp) {
|
||||
|
||||
}
|
||||
|
||||
} else if (!strncmp(env, "AFL_FUZZER_STATS_UPDATE_INTERVAL",
|
||||
|
||||
afl_environment_variable_len)) {
|
||||
|
||||
u64 stats_update_freq_sec =
|
||||
strtoull(get_afl_env(afl_environment_variables[i]), NULL, 0);
|
||||
if (stats_update_freq_sec >= UINT_MAX ||
|
||||
0 == stats_update_freq_sec) {
|
||||
|
||||
WARNF(
|
||||
"Incorrect value given to AFL_FUZZER_STATS_UPDATE_INTERVAL, "
|
||||
"using default of %d seconds\n",
|
||||
STATS_UPDATE_SEC);
|
||||
|
||||
} else {
|
||||
|
||||
afl->stats_file_update_freq_msecs = stats_update_freq_sec * 1000;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -611,9 +611,10 @@ void show_stats_normal(afl_state_t *afl) {
|
||||
|
||||
/* Roughly every minute, update fuzzer stats and save auto tokens. */
|
||||
|
||||
if (unlikely(!afl->non_instrumented_mode &&
|
||||
(afl->force_ui_update ||
|
||||
cur_ms - afl->stats_last_stats_ms > STATS_UPDATE_SEC * 1000))) {
|
||||
if (unlikely(
|
||||
!afl->non_instrumented_mode &&
|
||||
(afl->force_ui_update || cur_ms - afl->stats_last_stats_ms >
|
||||
afl->stats_file_update_freq_msecs))) {
|
||||
|
||||
afl->stats_last_stats_ms = cur_ms;
|
||||
write_stats_file(afl, t_bytes, t_byte_ratio, stab_ratio,
|
||||
|
@ -210,7 +210,8 @@ static void usage(u8 *argv0, int more_help) {
|
||||
" -b cpu_id - bind the fuzzing process to the specified CPU core "
|
||||
"(0-...)\n"
|
||||
" -e ext - file extension for the fuzz test input file (if "
|
||||
"needed)\n\n",
|
||||
"needed)\n"
|
||||
"\n",
|
||||
argv0, EXEC_TIMEOUT, MEM_LIMIT, MAX_FILE, FOREIGN_SYNCS_MAX);
|
||||
|
||||
if (more_help > 1) {
|
||||
@ -312,6 +313,8 @@ static void usage(u8 *argv0, int more_help) {
|
||||
" afl-clang-lto/afl-gcc-fast target\n"
|
||||
"AFL_PERSISTENT: enforce persistent mode (if __AFL_LOOP is in a shared lib\n"
|
||||
"AFL_DEFER_FORKSRV: enforced deferred forkserver (__AFL_INIT is in a .so)\n"
|
||||
"AFL_FUZZER_STATS_UPDATE_INTERVAL: interval to update fuzzer_stats file in seconds, "
|
||||
"(default: 60, minimum: 1)\n"
|
||||
"\n"
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user