about summary refs log tree commit diff
path: root/include
diff options
context:
space:
mode:
authorDominik Maier <domenukk@gmail.com>2020-04-14 19:27:25 +0200
committerDominik Maier <domenukk@gmail.com>2020-04-14 19:27:25 +0200
commit6dc36f1e6e7d2d781cc6b14f2898b3f7021e1d06 (patch)
tree1f46a247e84b0733935565b1513b6f2bdd4d797b /include
parentf4436f118c7a828e37926b948e997d1c8f5b2b03 (diff)
downloadafl++-6dc36f1e6e7d2d781cc6b14f2898b3f7021e1d06.tar.gz
unified forkservered run_target, fixes #308
Diffstat (limited to 'include')
-rw-r--r--include/afl-fuzz.h16
-rw-r--r--include/forkserver.h21
2 files changed, 19 insertions, 18 deletions
diff --git a/include/afl-fuzz.h b/include/afl-fuzz.h
index 3df99a58..abaa71b5 100644
--- a/include/afl-fuzz.h
+++ b/include/afl-fuzz.h
@@ -195,18 +195,6 @@ enum {
 
 };
 
-/* Execution status fault codes */
-
-enum {
-
-  /* 00 */ FAULT_NONE,
-  /* 01 */ FAULT_TMOUT,
-  /* 02 */ FAULT_CRASH,
-  /* 03 */ FAULT_ERROR,
-  /* 04 */ FAULT_NOINST,
-  /* 05 */ FAULT_NOBITS
-
-};
 
 #define operator_num 16
 #define swarm_num 5
@@ -433,7 +421,6 @@ typedef struct afl_state {
       use_splicing,                     /* Recombine input files?           */
       dumb_mode,                        /* Run in non-instrumented mode?    */
       score_changed,                    /* Scoring for favorites changed?   */
-      kill_signal,                      /* Signal that killed the child     */
       resuming_fuzz,                    /* Resuming an older fuzzing job?   */
       timeout_given,                    /* Specific timeout given?          */
       not_on_tty,                       /* stdout is not a tty              */
@@ -488,7 +475,6 @@ typedef struct afl_state {
       total_tmouts,                     /* Total number of timeouts         */
       unique_tmouts,                    /* Timeouts with unique signatures  */
       unique_hangs,                     /* Hangs with unique signatures     */
-      total_execs,                      /* Total execve() calls             */
       last_crash_execs,                 /* Exec counter at last crash       */
       queue_cycle,                      /* Queue round counter              */
       cycles_wo_finds,                  /* Cycles without any new paths     */
@@ -888,7 +874,7 @@ void show_init_stats(afl_state_t *);
 
 /* Run */
 
-u8   run_target(afl_state_t *, afl_forkserver_t *fsrv, u32);
+fsrv_run_result_t run_target(afl_state_t *, afl_forkserver_t *fsrv, u32);
 void write_to_testcase(afl_state_t *, void *, u32);
 u8   calibrate_case(afl_state_t *, struct queue_entry *, u8 *, u32, u8);
 void sync_fuzzers(afl_state_t *);
diff --git a/include/forkserver.h b/include/forkserver.h
index 6fbaf612..7559e785 100644
--- a/include/forkserver.h
+++ b/include/forkserver.h
@@ -29,6 +29,7 @@
 #define __AFL_FORKSERVER_H
 
 #include <stdio.h>
+#include <stdbool.h>
 
 typedef struct afl_forkserver {
 
@@ -55,16 +56,18 @@ typedef struct afl_forkserver {
   u32 snapshot;                         /* is snapshot feature used         */
   u64 mem_limit;                        /* Memory cap for child (MB)        */
 
+  u64 total_execs;                      /* How often run_target was called  */
+
   u8 *out_file,                         /* File to fuzz, if any             */
       *target_path;                                   /* Path of the target */
 
   FILE *plot_file;                      /* Gnuplot output file              */
 
-  u8 child_timed_out;                   /* Traced process timed out?        */
+  u8 last_run_timed_out;                   /* Traced process timed out?        */
 
-  u8 use_fauxsrv;                       /* Fauxsrv for non-forking targets? */
+  u8 last_kill_signal;                  /* Signal that killed the child     */
 
-  u32 prev_timed_out;                   /* if prev forkserver run timed out */
+  u8 use_fauxsrv;                       /* Fauxsrv for non-forking targets? */
 
   u8 qemu_mode;                         /* if running in qemu mode or not   */
 
@@ -79,10 +82,22 @@ typedef struct afl_forkserver {
 
 } afl_forkserver_t;
 
+typedef enum fsrv_run_result {
+
+  /* 00 */ FSRV_RUN_OK = 0,
+  /* 01 */ FSRV_RUN_TMOUT,
+  /* 02 */ FSRV_RUN_CRASH,
+  /* 03 */ FSRV_RUN_ERROR,
+  /* 04 */ FSRV_RUN_NOINST,
+  /* 05 */ FSRV_RUN_NOBITS,
+
+} fsrv_run_result_t;
+
 void afl_fsrv_init(afl_forkserver_t *fsrv);
 void afl_fsrv_init_dup(afl_forkserver_t *fsrv_to, afl_forkserver_t *from);
 void afl_fsrv_start(afl_forkserver_t *fsrv, char **argv,
                     volatile u8 *stop_soon_p, u8 debug_child_output);
+fsrv_run_result_t afl_fsrv_run_target(afl_forkserver_t *fsrv, volatile u8 *stop_soon_p);
 void afl_fsrv_killall(void);
 void afl_fsrv_deinit(afl_forkserver_t *fsrv);