diff --git a/afl/src/events/llmp.rs b/afl/src/events/llmp.rs index 153db7e7cb..dc2b23c90f 100644 --- a/afl/src/events/llmp.rs +++ b/afl/src/events/llmp.rs @@ -21,6 +21,7 @@ use crate::{ feedbacks::FeedbacksTuple, inputs::Input, state::State, + executors::ExitKind, stats::Stats, utils::Rand, AflError, @@ -278,7 +279,8 @@ where #[cfg(feature = "std")] println!("Received new Testcase"); let observers = postcard::from_bytes(&observers_buf)?; - let interestingness = state.is_interesting(&input, &observers)?; + // TODO include ExitKind in NewTestcase + let interestingness = state.is_interesting(&input, &observers, ExitKind::Ok)?; state.add_if_interesting(input, interestingness)?; Ok(()) } diff --git a/afl/src/executors/mod.rs b/afl/src/executors/mod.rs index 5335d89648..da0e2b94e7 100644 --- a/afl/src/executors/mod.rs +++ b/afl/src/executors/mod.rs @@ -20,6 +20,7 @@ use crate::{ }; /// How an execution finished. +#[derive(Debug, Clone)] pub enum ExitKind { Ok, Crash, diff --git a/afl/src/feedbacks/mod.rs b/afl/src/feedbacks/mod.rs index 95428e813e..8d3651ae9c 100644 --- a/afl/src/feedbacks/mod.rs +++ b/afl/src/feedbacks/mod.rs @@ -11,6 +11,7 @@ use serde::{Deserialize, Serialize}; use crate::{ bolts::tuples::{Named, TupleList}, + executors::ExitKind, corpus::Testcase, inputs::Input, observers::{MapObserver, Observer, ObserversTuple}, @@ -35,6 +36,7 @@ where &mut self, input: &I, observers: &OT, + exit_kind: ExitKind, ) -> Result; /// Append to the testcase the generated metadata in case of a new corpus item @@ -83,6 +85,7 @@ where &mut self, input: &I, observers: &OT, + exit_kind: ExitKind, ) -> Result; /// Write metadata for this testcase @@ -103,7 +106,7 @@ where I: Input, { #[inline] - fn is_interesting_all(&mut self, _: &I, _: &OT) -> Result { + fn is_interesting_all(&mut self, _: &I, _: &OT, _: ExitKind,) -> Result { Ok(0) } @@ -134,9 +137,10 @@ where &mut self, input: &I, observers: &OT, + exit_kind: ExitKind, ) -> Result { - Ok(self.0.is_interesting(input, observers)? - + self.1.is_interesting_all(input, observers)?) + Ok(self.0.is_interesting(input, observers, exit_kind.clone())? + + self.1.is_interesting_all(input, observers, exit_kind)?) } fn append_metadata_all(&mut self, testcase: &mut Testcase) -> Result<(), AflError> { @@ -243,6 +247,7 @@ where &mut self, _input: &I, observers: &OT, + _exit_kind: ExitKind, ) -> Result { let mut interesting = 0; // TODO optimize diff --git a/afl/src/stages/mutational.rs b/afl/src/stages/mutational.rs index f4f737bad1..f18421f3a8 100644 --- a/afl/src/stages/mutational.rs +++ b/afl/src/stages/mutational.rs @@ -81,7 +81,6 @@ where if fitness > 0 { let observers_buf = manager.serialize_observers(observers)?; - // TODO decouple events manager and engine manager.fire( state, Event::NewTestcase { diff --git a/afl/src/state/mod.rs b/afl/src/state/mod.rs index 4472177014..c32d6b9836 100644 --- a/afl/src/state/mod.rs +++ b/afl/src/state/mod.rs @@ -12,7 +12,7 @@ use crate::{ bolts::serdeany::{SerdeAny, SerdeAnyMap}, corpus::{Corpus, Testcase}, events::{Event, EventManager, LogSeverity}, - executors::{Executor, HasObservers}, + executors::{Executor, HasObservers, ExitKind}, feedbacks::FeedbacksTuple, generators::Generator, inputs::Input, @@ -248,11 +248,11 @@ where // TODO move some of these, like evaluate_input, to FuzzingEngine #[inline] - pub fn is_interesting(&mut self, input: &I, observers: &OT) -> Result + pub fn is_interesting(&mut self, input: &I, observers: &OT, exit_kind: ExitKind) -> Result where OT: ObserversTuple, { - Ok(self.feedbacks_mut().is_interesting_all(input, observers)?) + Ok(self.feedbacks_mut().is_interesting_all(input, observers, exit_kind)?) } /// Runs the input and triggers observers and feedback @@ -271,14 +271,14 @@ where executor.pre_exec_observers()?; executor.pre_exec(self, event_mgr, input)?; - executor.run_target(input)?; + let exit_kind = executor.run_target(input)?; executor.post_exec(&self, event_mgr, input)?; self.set_executions(self.executions() + 1); executor.post_exec_observers()?; let observers = executor.observers(); - let fitness = self.feedbacks_mut().is_interesting_all(&input, observers)?; + let fitness = self.feedbacks_mut().is_interesting_all(&input, observers, exit_kind)?; Ok(fitness) }