Scalability introspector + State refactor (#1674)

* check

* clippy fmt fixing all the stuff

* restore Cargo.toml

* a

* ci

* ci

* a

* a

* workging?

* work

* ?

* why it worksgit add -u

* ci

* ci

* TMATE

* ci

* ci

* ci

* remove tmate

* less

* fuck; let's try with introspection first

* fucking macro

* another windows shit

* stop it

* i'm harassed by how shit windows is

* fixing

* ci

* ziopera

* fix from main

* ci

* ci
This commit is contained in:
Dongjia "toka" Zhang 2023-11-21 14:38:48 +01:00 committed by GitHub
parent 86cb187ef1
commit 379e2ae89b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 494 additions and 481 deletions

View File

@ -3,10 +3,9 @@ use libafl::{
events::EventFirer,
executors::ExitKind,
feedbacks::{Feedback, MapIndexesMetadata},
inputs::UsesInput,
observers::ObserversTuple,
schedulers::{MinimizerScheduler, TestcaseScore},
state::{HasClientPerfMonitor, HasCorpus, HasMetadata},
state::{HasCorpus, HasMetadata, State},
Error,
};
use libafl_bolts::{Named, SerdeAny};
@ -43,7 +42,7 @@ pub struct PacketLenFeedback {
impl<S> Feedback<S> for PacketLenFeedback
where
S: UsesInput<Input = PacketData> + HasClientPerfMonitor,
S: State<Input = PacketData>,
{
#[inline]
fn is_interesting<EM, OT>(

View File

@ -29,6 +29,9 @@ std = ["serde_json", "serde_json/std", "nix", "serde/std", "bincode", "wait-time
## Collects performance statistics of the fuzzing pipeline and displays it on `Monitor` components
introspection = []
## Collects stats about scalability
scalability_introspecition = []
## Will build the `pyo3` bindings
python = ["pyo3", "concat-idents", "libafl_bolts/python"]

View File

@ -29,7 +29,7 @@ use crate::{
fuzzer::{EvaluatorObservers, ExecutionProcessor},
inputs::{Input, UsesInput},
observers::ObserversTuple,
state::{HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata, UsesState},
state::{HasExecutions, HasLastReportTime, HasMetadata, UsesState},
Error,
};
@ -417,7 +417,7 @@ where
impl<E, EM, SP, Z> EventManager<E, Z> for CentralizedEventManager<EM, SP>
where
EM: EventStatsCollector + EventManager<E, Z>,
EM::State: HasClientPerfMonitor + HasExecutions + HasMetadata + HasLastReportTime,
EM::State: HasExecutions + HasMetadata + HasLastReportTime,
E: HasObservers<State = Self::State> + Executor<Self, Z>,
for<'a> E::Observers: Deserialize<'a>,
Z: EvaluatorObservers<E::Observers, State = Self::State>
@ -445,7 +445,7 @@ where
impl<EM, SP> ProgressReporter for CentralizedEventManager<EM, SP>
where
EM: EventStatsCollector + ProgressReporter + HasEventManagerId,
EM::State: HasClientPerfMonitor + HasMetadata + HasExecutions + HasLastReportTime,
EM::State: HasMetadata + HasExecutions + HasLastReportTime,
SP: ShMemProvider + 'static,
{
}
@ -652,13 +652,27 @@ where
} => {
log::info!("Received new Testcase from {client_id:?} ({client_config:?}, forward {forward_id:?})");
#[cfg(feature = "scalability_introspection")]
println!(
"{} {}",
state.scalability_monitor().testcase_with_observers,
state.scalability_monitor().testcase_without_observers
);
let res = if client_config.match_with(&self.configuration())
&& observers_buf.is_some()
{
let observers: E::Observers =
postcard::from_bytes(observers_buf.as_ref().unwrap())?;
#[cfg(feature = "scalability_introspection")]
{
state.scalability_monitor_mut().testcase_with_observers += 1;
}
fuzzer.process_execution(state, self, input, &observers, &exit_kind, true)?
} else {
#[cfg(feature = "scalability_introspection")]
{
state.scalability_monitor_mut().testcase_without_observers += 1;
}
let res = fuzzer.evaluate_input_with_observers::<E, Self>(
state,
executor,

View File

@ -38,18 +38,15 @@ use libafl_bolts::{
shmem::ShMemProvider,
};
#[cfg(feature = "std")]
use serde::de::DeserializeOwned;
#[cfg(feature = "std")]
use typed_builder::TypedBuilder;
#[cfg(all(unix, feature = "std", feature = "fork"))]
use crate::events::{CentralizedEventManager, CentralizedLlmpEventBroker};
use crate::inputs::UsesInput;
#[cfg(feature = "std")]
use crate::{
events::{EventConfig, LlmpRestartingEventManager, ManagerKind, RestartingMgr},
monitors::Monitor,
state::{HasClientPerfMonitor, HasExecutions},
state::{HasExecutions, State},
Error,
};
@ -76,7 +73,7 @@ where
S::Input: 'a,
MT: Monitor,
SP: ShMemProvider + 'static,
S: DeserializeOwned + UsesInput + 'a,
S: State + 'a,
{
/// The ShmemProvider to use
shmem_provider: SP,
@ -121,7 +118,7 @@ where
CF: FnOnce(Option<S>, LlmpRestartingEventManager<S, SP>, CoreId) -> Result<(), Error>,
MT: Monitor + Clone,
SP: ShMemProvider + 'static,
S: DeserializeOwned + UsesInput,
S: State,
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("Launcher")
@ -141,7 +138,7 @@ impl<'a, CF, MT, S, SP> Launcher<'a, CF, MT, S, SP>
where
CF: FnOnce(Option<S>, LlmpRestartingEventManager<S, SP>, CoreId) -> Result<(), Error>,
MT: Monitor + Clone,
S: DeserializeOwned + UsesInput + HasExecutions + HasClientPerfMonitor,
S: State + HasExecutions,
SP: ShMemProvider + 'static,
{
/// Launch the broker and the clients and fuzz
@ -401,7 +398,7 @@ where
S::Input: 'a,
MT: Monitor,
SP: ShMemProvider + 'static,
S: DeserializeOwned + UsesInput + 'a,
S: State + 'a,
{
/// The ShmemProvider to use
shmem_provider: SP,
@ -454,7 +451,7 @@ where
) -> Result<(), Error>,
MT: Monitor + Clone,
SP: ShMemProvider + 'static,
S: DeserializeOwned + UsesInput,
S: State,
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("Launcher")
@ -478,7 +475,7 @@ where
CoreId,
) -> Result<(), Error>,
MT: Monitor + Clone,
S: DeserializeOwned + UsesInput + HasExecutions + HasClientPerfMonitor,
S: State + HasExecutions,
SP: ShMemProvider + 'static,
{
/// Launch the broker and the clients and fuzz

View File

@ -52,7 +52,7 @@ use crate::{
inputs::{Input, InputConverter, UsesInput},
monitors::Monitor,
observers::ObserversTuple,
state::{HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata, UsesState},
state::{HasExecutions, HasLastReportTime, HasMetadata, State, UsesState},
Error,
};
@ -345,7 +345,7 @@ pub trait EventStatsCollector {}
/// using low-level message passing, [`libafl_bolts::llmp`].
pub struct LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
{
/// The LLMP client for inter process communication
@ -373,7 +373,7 @@ where
impl<S, SP> EventStatsCollector for LlmpEventManager<S, SP>
where
SP: ShMemProvider + 'static,
S: UsesInput,
S: State,
{
fn serialization_time(&self) -> Duration {
self.serialization_time
@ -405,7 +405,7 @@ where
impl<S, SP> core::fmt::Debug for LlmpEventManager<S, SP>
where
SP: ShMemProvider + 'static,
S: UsesInput,
S: State,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut debug_struct = f.debug_struct("LlmpEventManager");
@ -423,7 +423,7 @@ where
impl<S, SP> Drop for LlmpEventManager<S, SP>
where
SP: ShMemProvider + 'static,
S: UsesInput,
S: State,
{
/// LLMP clients will have to wait until their pages are mapped by somebody.
fn drop(&mut self) {
@ -433,7 +433,7 @@ where
impl<S, SP> LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
{
/// Create a manager from a raw LLMP client
@ -549,7 +549,7 @@ where
impl<S, SP> LlmpEventManager<S, SP>
where
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata,
S: State + HasExecutions + HasMetadata,
SP: ShMemProvider + 'static,
{
// Handle arriving events in the client
@ -591,9 +591,16 @@ where
{
self.deserialization_time = current_time() - start;
}
#[cfg(feature = "scalability_introspection")]
{
state.scalability_monitor_mut().testcase_with_observers += 1;
}
fuzzer.process_execution(state, self, input, &observers, &exit_kind, false)?
} else {
#[cfg(feature = "scalability_introspection")]
{
state.scalability_monitor_mut().testcase_without_observers += 1;
}
fuzzer.evaluate_input_with_observers::<E, Self>(
state, executor, self, input, false,
)?
@ -619,7 +626,7 @@ where
}
}
impl<S: UsesInput, SP: ShMemProvider> LlmpEventManager<S, SP> {
impl<S: State, SP: ShMemProvider> LlmpEventManager<S, SP> {
/// Send information that this client is exiting.
/// The other side may free up all allocated memory.
/// We are no longer allowed to send anything afterwards.
@ -630,7 +637,7 @@ impl<S: UsesInput, SP: ShMemProvider> LlmpEventManager<S, SP> {
impl<S, SP> UsesState for LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -638,7 +645,7 @@ where
impl<S, SP> EventFirer for LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
#[cfg(feature = "llmp_compression")]
@ -732,7 +739,7 @@ where
impl<S, SP> EventRestarter for LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
/// The LLMP client needs to wait until a broker has mapped all pages before shutting down.
@ -745,7 +752,7 @@ where
impl<E, S, SP, Z> EventProcessor<E, Z> for LlmpEventManager<S, SP>
where
S: UsesInput + HasClientPerfMonitor + HasExecutions + HasMetadata,
S: State + HasExecutions + HasMetadata,
SP: ShMemProvider,
E: HasObservers<State = S> + Executor<Self, Z>,
for<'a> E::Observers: Deserialize<'a>,
@ -792,7 +799,7 @@ impl<E, S, SP, Z> EventManager<E, Z> for LlmpEventManager<S, SP>
where
E: HasObservers<State = S> + Executor<Self, Z>,
for<'a> E::Observers: Deserialize<'a>,
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata + HasLastReportTime,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers, State = S>,
{
@ -800,7 +807,7 @@ where
impl<S, SP> HasCustomBufHandlers for LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
fn add_custom_buf_handler(
@ -813,14 +820,14 @@ where
impl<S, SP> ProgressReporter for LlmpEventManager<S, SP>
where
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata + HasLastReportTime,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider,
{
}
impl<S, SP> HasEventManagerId for LlmpEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
/// Gets the id assigned to this staterestorer.
@ -834,7 +841,7 @@ where
#[derive(Debug)]
pub struct LlmpRestartingEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
//CE: CustomEvent<I>,
{
@ -850,7 +857,7 @@ where
impl<S, SP> EventStatsCollector for LlmpRestartingEventManager<S, SP>
where
SP: ShMemProvider + 'static,
S: UsesInput,
S: State,
{
fn serialization_time(&self) -> Duration {
self.llmp_mgr.serialization_time()
@ -883,14 +890,14 @@ where
impl<S, SP> EventStatsCollector for LlmpRestartingEventManager<S, SP>
where
SP: ShMemProvider + 'static,
S: UsesInput,
S: State,
{
}
#[cfg(feature = "std")]
impl<S, SP> UsesState for LlmpRestartingEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
{
type State = S;
@ -899,12 +906,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> ProgressReporter for LlmpRestartingEventManager<S, SP>
where
S: UsesInput
+ HasExecutions
+ HasClientPerfMonitor
+ HasMetadata
+ HasLastReportTime
+ Serialize,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider,
{
}
@ -913,7 +915,7 @@ where
impl<S, SP> EventFirer for LlmpRestartingEventManager<S, SP>
where
SP: ShMemProvider,
S: UsesInput,
S: State,
//CE: CustomEvent<I>,
{
fn fire(
@ -940,7 +942,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> EventRestarter for LlmpRestartingEventManager<S, SP>
where
S: UsesInput + HasExecutions + HasClientPerfMonitor + Serialize,
S: State + HasExecutions,
SP: ShMemProvider,
//CE: CustomEvent<I>,
{
@ -978,7 +980,7 @@ impl<E, S, SP, Z> EventProcessor<E, Z> for LlmpRestartingEventManager<S, SP>
where
E: HasObservers<State = S> + Executor<LlmpEventManager<S, SP>, Z>,
for<'a> E::Observers: Deserialize<'a>,
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata,
S: State + HasExecutions + HasMetadata,
SP: ShMemProvider + 'static,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers>, //CE: CustomEvent<I>,
{
@ -992,12 +994,7 @@ impl<E, S, SP, Z> EventManager<E, Z> for LlmpRestartingEventManager<S, SP>
where
E: HasObservers<State = S> + Executor<LlmpEventManager<S, SP>, Z>,
for<'a> E::Observers: Deserialize<'a>,
S: UsesInput
+ HasExecutions
+ HasClientPerfMonitor
+ HasMetadata
+ HasLastReportTime
+ Serialize,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider + 'static,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers>, //CE: CustomEvent<I>,
{
@ -1006,7 +1003,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> HasEventManagerId for LlmpRestartingEventManager<S, SP>
where
S: UsesInput + Serialize,
S: State,
SP: ShMemProvider + 'static,
{
fn mgr_id(&self) -> EventManagerId {
@ -1023,7 +1020,7 @@ const _ENV_FUZZER_BROKER_CLIENT_INITIAL: &str = "_AFL_ENV_FUZZER_BROKER_CLIENT";
#[cfg(feature = "std")]
impl<S, SP> LlmpRestartingEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
//CE: CustomEvent<I>,
{
@ -1087,7 +1084,7 @@ pub fn setup_restarting_mgr_std<MT, S>(
) -> Result<(Option<S>, LlmpRestartingEventManager<S, StdShMemProvider>), Error>
where
MT: Monitor + Clone,
S: DeserializeOwned + UsesInput + HasClientPerfMonitor + HasExecutions,
S: State + HasExecutions,
{
RestartingMgr::builder()
.shmem_provider(StdShMemProvider::new()?)
@ -1148,7 +1145,7 @@ where
impl<MT, S, SP> RestartingMgr<MT, S, SP>
where
SP: ShMemProvider,
S: UsesInput + HasExecutions + HasClientPerfMonitor + DeserializeOwned,
S: State + HasExecutions,
MT: Monitor + Clone,
{
/// Launch the restarting manager
@ -1412,7 +1409,7 @@ where
impl<IC, ICB, DI, S, SP> LlmpEventConverter<IC, ICB, DI, S, SP>
where
S: UsesInput + HasExecutions + HasClientPerfMonitor,
S: UsesInput + HasExecutions,
SP: ShMemProvider + 'static,
IC: InputConverter<From = S::Input, To = DI>,
ICB: InputConverter<From = DI, To = S::Input>,
@ -1605,7 +1602,7 @@ where
impl<IC, ICB, DI, S, SP> UsesState for LlmpEventConverter<IC, ICB, DI, S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
IC: InputConverter<From = S::Input, To = DI>,
ICB: InputConverter<From = DI, To = S::Input>,
@ -1616,7 +1613,7 @@ where
impl<IC, ICB, DI, S, SP> EventFirer for LlmpEventConverter<IC, ICB, DI, S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
IC: InputConverter<From = S::Input, To = DI>,
ICB: InputConverter<From = DI, To = S::Input>,

View File

@ -38,12 +38,14 @@ use serde::{Deserialize, Serialize};
#[cfg(feature = "std")]
use uuid::Uuid;
#[cfg(feature = "introspection")]
use crate::state::HasClientPerfMonitor;
use crate::{
executors::ExitKind,
inputs::Input,
monitors::UserStats,
observers::ObserversTuple,
state::{HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata},
state::{HasExecutions, HasLastReportTime, HasMetadata, State},
Error,
};
@ -462,7 +464,7 @@ pub trait EventFirer: UsesState {
/// [`ProgressReporter`] report progress to the broker.
pub trait ProgressReporter: EventFirer
where
Self::State: HasClientPerfMonitor + HasMetadata + HasExecutions + HasLastReportTime,
Self::State: HasMetadata + HasExecutions + HasLastReportTime,
{
/// Given the last time, if `monitor_timeout` seconds passed, send off an info/monitor/heartbeat message to the broker.
/// Returns the new `last` time (so the old one, unless `monitor_timeout` time has passed and monitor have been sent)
@ -574,7 +576,7 @@ pub trait HasEventManagerId {
pub trait EventManager<E, Z>:
EventFirer + EventProcessor<E, Z> + EventRestarter + HasEventManagerId + ProgressReporter
where
Self::State: HasClientPerfMonitor + HasMetadata + HasExecutions + HasLastReportTime,
Self::State: HasMetadata + HasExecutions + HasLastReportTime,
{
}
@ -606,14 +608,14 @@ impl<S> NopEventManager<S> {
impl<S> UsesState for NopEventManager<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S> EventFirer for NopEventManager<S>
where
S: UsesInput,
S: State,
{
fn fire(
&mut self,
@ -624,11 +626,11 @@ where
}
}
impl<S> EventRestarter for NopEventManager<S> where S: UsesInput {}
impl<S> EventRestarter for NopEventManager<S> where S: State {}
impl<E, S, Z> EventProcessor<E, Z> for NopEventManager<S>
where
S: UsesInput + HasClientPerfMonitor + HasExecutions,
S: State + HasExecutions,
{
fn process(
&mut self,
@ -641,13 +643,13 @@ where
}
impl<E, S, Z> EventManager<E, Z> for NopEventManager<S> where
S: UsesInput + HasClientPerfMonitor + HasExecutions + HasLastReportTime + HasMetadata
S: State + HasExecutions + HasLastReportTime + HasMetadata
{
}
impl<S> HasCustomBufHandlers for NopEventManager<S>
where
S: UsesInput,
S: State,
{
fn add_custom_buf_handler(
&mut self,
@ -659,7 +661,7 @@ where
}
impl<S> ProgressReporter for NopEventManager<S> where
S: UsesInput + HasClientPerfMonitor + HasExecutions + HasLastReportTime + HasMetadata
S: State + HasExecutions + HasLastReportTime + HasMetadata
{
}

View File

@ -38,7 +38,7 @@ use crate::{
},
inputs::UsesInput,
monitors::Monitor,
state::{HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata, UsesState},
state::{HasExecutions, HasLastReportTime, HasMetadata, State, UsesState},
Error,
};
#[cfg(feature = "std")]
@ -83,7 +83,7 @@ where
impl<MT, S> UsesState for SimpleEventManager<MT, S>
where
S: UsesInput,
S: State,
{
type State = S;
}
@ -91,7 +91,7 @@ where
impl<MT, S> EventFirer for SimpleEventManager<MT, S>
where
MT: Monitor,
S: UsesInput,
S: State,
{
fn fire(
&mut self,
@ -109,14 +109,14 @@ where
impl<MT, S> EventRestarter for SimpleEventManager<MT, S>
where
MT: Monitor,
S: UsesInput,
S: State,
{
}
impl<E, MT, S, Z> EventProcessor<E, Z> for SimpleEventManager<MT, S>
where
MT: Monitor,
S: UsesInput,
S: State,
{
fn process(
&mut self,
@ -135,14 +135,14 @@ where
impl<E, MT, S, Z> EventManager<E, Z> for SimpleEventManager<MT, S>
where
MT: Monitor,
S: UsesInput + HasClientPerfMonitor + HasExecutions + HasLastReportTime + HasMetadata,
S: State + HasExecutions + HasLastReportTime + HasMetadata,
{
}
impl<MT, S> HasCustomBufHandlers for SimpleEventManager<MT, S>
where
MT: Monitor, //CE: CustomEvent<I, OT>,
S: UsesInput,
S: State,
{
/// Adds a custom buffer handler that will run for each incoming `CustomBuf` event.
fn add_custom_buf_handler(
@ -158,7 +158,7 @@ where
impl<MT, S> ProgressReporter for SimpleEventManager<MT, S>
where
MT: Monitor,
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata + HasLastReportTime,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
{
}
@ -320,7 +320,7 @@ where
#[cfg(feature = "std")]
impl<MT, S, SP> UsesState for SimpleRestartingEventManager<MT, S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -330,7 +330,7 @@ where
impl<MT, S, SP> EventFirer for SimpleRestartingEventManager<MT, S, SP>
where
MT: Monitor,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
fn fire(
@ -346,7 +346,7 @@ where
impl<MT, S, SP> EventRestarter for SimpleRestartingEventManager<MT, S, SP>
where
MT: Monitor,
S: UsesInput + Serialize,
S: State,
SP: ShMemProvider,
{
/// Reset the single page (we reuse it over and over from pos 0), then send the current state to the next runner.
@ -370,7 +370,7 @@ where
impl<E, MT, S, SP, Z> EventProcessor<E, Z> for SimpleRestartingEventManager<MT, S, SP>
where
MT: Monitor,
S: UsesInput + HasClientPerfMonitor + HasExecutions + Serialize,
S: State + HasExecutions,
SP: ShMemProvider,
{
fn process(
@ -387,12 +387,7 @@ where
impl<E, MT, S, SP, Z> EventManager<E, Z> for SimpleRestartingEventManager<MT, S, SP>
where
MT: Monitor,
S: UsesInput
+ HasExecutions
+ HasClientPerfMonitor
+ HasMetadata
+ HasLastReportTime
+ Serialize,
S: State + HasExecutions + HasMetadata + HasLastReportTime + Serialize,
SP: ShMemProvider,
{
}
@ -401,7 +396,7 @@ where
impl<MT, S, SP> HasCustomBufHandlers for SimpleRestartingEventManager<MT, S, SP>
where
MT: Monitor,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
fn add_custom_buf_handler(
@ -416,7 +411,7 @@ where
impl<MT, S, SP> ProgressReporter for SimpleRestartingEventManager<MT, S, SP>
where
MT: Monitor,
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata + HasLastReportTime,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider,
{
}

View File

@ -28,7 +28,7 @@ use libafl_bolts::os::{fork, ForkResult};
use libafl_bolts::{shmem::ShMemProvider, ClientId};
#[cfg(feature = "std")]
use libafl_bolts::{shmem::StdShMemProvider, staterestore::StateRestorer};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use serde::{de::DeserializeOwned, Deserialize};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
sync::{broadcast, broadcast::error::RecvError, mpsc},
@ -49,7 +49,7 @@ use crate::{
fuzzer::{EvaluatorObservers, ExecutionProcessor},
inputs::{Input, UsesInput},
monitors::Monitor,
state::{HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata, UsesState},
state::{HasExecutions, HasLastReportTime, HasMetadata, State, UsesState},
Error,
};
@ -407,7 +407,7 @@ where
/// An [`EventManager`] that forwards all events to other attached via tcp.
pub struct TcpEventManager<S>
where
S: UsesInput,
S: State,
{
/// The TCP stream for inter process communication
tcp: TcpStream,
@ -426,7 +426,7 @@ where
impl<S> core::fmt::Debug for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut debug_struct = f.debug_struct("TcpEventManager");
@ -443,7 +443,7 @@ where
impl<S> Drop for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
/// TCP clients will have to wait until their pages are mapped by somebody.
fn drop(&mut self) {
@ -453,7 +453,7 @@ where
impl<S> TcpEventManager<S>
where
S: UsesInput + HasExecutions + HasClientPerfMonitor,
S: State + HasExecutions,
{
/// Create a manager from a raw TCP client specifying the client id
pub fn existing<A: ToSocketAddrs>(
@ -560,8 +560,16 @@ where
{
let observers: E::Observers =
postcard::from_bytes(observers_buf.as_ref().unwrap())?;
#[cfg(feature = "scalability_introspection")]
{
state.scalability_monitor_mut().testcase_with_observers += 1;
}
fuzzer.process_execution(state, self, input, &observers, &exit_kind, false)?
} else {
#[cfg(feature = "scalability_introspection")]
{
state.scalability_monitor_mut().testcase_without_observers += 1;
}
fuzzer.evaluate_input_with_observers::<E, Self>(
state, executor, self, input, false,
)?
@ -589,7 +597,7 @@ where
impl<S> TcpEventManager<S>
where
S: UsesInput,
S: State,
{
/// Send information that this client is exiting.
/// The other side may free up all allocated memory.
@ -603,14 +611,14 @@ where
impl<S> UsesState for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S> EventFirer for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
#[cfg(feature = "tcp_compression")]
fn fire(
@ -657,7 +665,7 @@ where
impl<S> EventRestarter for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
/// The TCP client needs to wait until a broker has mapped all pages before shutting down.
/// Otherwise, the OS may already have removed the shared maps.
@ -669,7 +677,7 @@ where
impl<E, S, Z> EventProcessor<E, Z> for TcpEventManager<S>
where
S: UsesInput + HasClientPerfMonitor + HasExecutions,
S: State + HasExecutions,
E: HasObservers<State = S> + Executor<Self, Z>,
for<'a> E::Observers: Deserialize<'a>,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers, State = S>,
@ -732,14 +740,14 @@ impl<E, S, Z> EventManager<E, Z> for TcpEventManager<S>
where
E: HasObservers<State = S> + Executor<Self, Z>,
for<'a> E::Observers: Deserialize<'a>,
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata + HasLastReportTime,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers, State = S>,
{
}
impl<S> HasCustomBufHandlers for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
fn add_custom_buf_handler(
&mut self,
@ -750,13 +758,13 @@ where
}
impl<S> ProgressReporter for TcpEventManager<S> where
S: UsesInput + HasExecutions + HasClientPerfMonitor + HasMetadata + HasLastReportTime
S: State + HasExecutions + HasMetadata + HasLastReportTime
{
}
impl<S> HasEventManagerId for TcpEventManager<S>
where
S: UsesInput,
S: State,
{
/// Gets the id assigned to this staterestorer.
fn mgr_id(&self) -> EventManagerId {
@ -769,7 +777,7 @@ where
#[derive(Debug)]
pub struct TcpRestartingEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
//CE: CustomEvent<I>,
{
@ -784,7 +792,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> UsesState for TcpRestartingEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
{
type State = S;
@ -793,12 +801,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> ProgressReporter for TcpRestartingEventManager<S, SP>
where
S: UsesInput
+ HasExecutions
+ HasClientPerfMonitor
+ HasMetadata
+ HasLastReportTime
+ Serialize,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider,
{
}
@ -807,7 +810,7 @@ where
impl<S, SP> EventFirer for TcpRestartingEventManager<S, SP>
where
SP: ShMemProvider,
S: UsesInput,
S: State,
//CE: CustomEvent<I>,
{
fn fire(
@ -827,7 +830,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> EventRestarter for TcpRestartingEventManager<S, SP>
where
S: UsesInput + HasExecutions + HasClientPerfMonitor + Serialize,
S: State + HasExecutions,
SP: ShMemProvider,
//CE: CustomEvent<I>,
{
@ -864,7 +867,7 @@ impl<E, S, SP, Z> EventProcessor<E, Z> for TcpRestartingEventManager<S, SP>
where
E: HasObservers<State = S> + Executor<TcpEventManager<S>, Z>,
for<'a> E::Observers: Deserialize<'a>,
S: UsesInput + HasExecutions + HasClientPerfMonitor,
S: State + HasExecutions,
SP: ShMemProvider + 'static,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers>, //CE: CustomEvent<I>,
{
@ -878,12 +881,7 @@ impl<E, S, SP, Z> EventManager<E, Z> for TcpRestartingEventManager<S, SP>
where
E: HasObservers<State = S> + Executor<TcpEventManager<S>, Z>,
for<'a> E::Observers: Deserialize<'a>,
S: UsesInput
+ HasExecutions
+ HasClientPerfMonitor
+ HasMetadata
+ HasLastReportTime
+ Serialize,
S: State + HasExecutions + HasMetadata + HasLastReportTime,
SP: ShMemProvider + 'static,
Z: EvaluatorObservers<E::Observers, State = S> + ExecutionProcessor<E::Observers>, //CE: CustomEvent<I>,
{
@ -892,7 +890,7 @@ where
#[cfg(feature = "std")]
impl<S, SP> HasEventManagerId for TcpRestartingEventManager<S, SP>
where
S: UsesInput + Serialize,
S: State,
SP: ShMemProvider + 'static,
{
fn mgr_id(&self) -> EventManagerId {
@ -909,7 +907,7 @@ const _ENV_FUZZER_BROKER_CLIENT_INITIAL: &str = "_AFL_ENV_FUZZER_BROKER_CLIENT";
#[cfg(feature = "std")]
impl<S, SP> TcpRestartingEventManager<S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider + 'static,
//CE: CustomEvent<I>,
{
@ -973,7 +971,7 @@ pub fn setup_restarting_mgr_tcp<MT, S>(
) -> Result<(Option<S>, TcpRestartingEventManager<S, StdShMemProvider>), Error>
where
MT: Monitor + Clone,
S: DeserializeOwned + UsesInput + HasClientPerfMonitor + HasExecutions,
S: State + HasExecutions,
{
RestartingMgr::builder()
.shmem_provider(StdShMemProvider::new()?)
@ -1034,7 +1032,7 @@ where
impl<MT, S, SP> RestartingMgr<MT, S, SP>
where
SP: ShMemProvider,
S: UsesInput + HasExecutions + HasClientPerfMonitor + DeserializeOwned,
S: State + HasExecutions,
MT: Monitor + Clone,
{
/// Launch the restarting manager

View File

@ -30,7 +30,7 @@ use crate::{inputs::Input, Error};
use crate::{
inputs::{HasTargetBytes, UsesInput},
observers::{ObserversTuple, UsesObservers},
state::{HasExecutions, UsesState},
state::{HasExecutions, State, UsesState},
std::borrow::ToOwned,
};
@ -313,7 +313,7 @@ where
impl<EM, OT, S, T, Z> Executor<EM, Z> for CommandExecutor<OT, S, T>
where
EM: UsesState<State = S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
S::Input: HasTargetBytes,
T: CommandConfigurator,
OT: Debug + MatchName + ObserversTuple<S>,
@ -378,7 +378,7 @@ where
impl<OT, S, T> UsesState for CommandExecutor<OT, S, T>
where
S: UsesInput,
S: State,
{
type State = S;
}
@ -386,14 +386,14 @@ where
impl<OT, S, T> UsesObservers for CommandExecutor<OT, S, T>
where
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
{
type Observers = OT;
}
impl<OT, S, T> HasObservers for CommandExecutor<OT, S, T>
where
S: UsesInput,
S: State,
T: Debug,
OT: ObserversTuple<S>,
{

View File

@ -39,7 +39,7 @@ use crate::{
inputs::{HasTargetBytes, Input, UsesInput},
mutators::Tokens,
observers::{MapObserver, Observer, ObserversTuple, UsesObservers},
state::{HasExecutions, UsesState},
state::{HasExecutions, State, UsesState},
Error,
};
@ -1213,7 +1213,7 @@ impl<EM, OT, S, SP, Z> Executor<EM, Z> for ForkserverExecutor<OT, S, SP>
where
OT: ObserversTuple<S>,
SP: ShMemProvider,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
S::Input: HasTargetBytes,
EM: UsesState<State = S>,
Z: UsesState<State = S>,
@ -1321,7 +1321,7 @@ where
impl<OT, S, SP> UsesState for ForkserverExecutor<OT, S, SP>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -1330,7 +1330,7 @@ where
impl<OT, S, SP> UsesObservers for ForkserverExecutor<OT, S, SP>
where
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type Observers = OT;
@ -1339,7 +1339,7 @@ where
impl<OT, S, SP> HasObservers for ForkserverExecutor<OT, S, SP>
where
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
#[inline]

View File

@ -53,7 +53,7 @@ use crate::{
fuzzer::HasObjective,
inputs::UsesInput,
observers::{ObserversTuple, UsesObservers},
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions, UsesState},
state::{HasCorpus, HasExecutions, HasSolutions, State, UsesState},
Error,
};
@ -75,7 +75,7 @@ where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
{
/// The harness function, being executed for each fuzzing loop execution
harness_fn: HB,
@ -91,7 +91,7 @@ where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S> + Debug,
S: UsesInput,
S: State,
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("GenericInProcessExecutor")
@ -106,7 +106,7 @@ where
H: ?Sized + FnMut(&S::Input) -> ExitKind,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
{
type State = S;
}
@ -116,7 +116,7 @@ where
H: ?Sized + FnMut(&S::Input) -> ExitKind,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
{
type Observers = OT;
}
@ -127,7 +127,7 @@ where
HB: BorrowMut<H>,
EM: UsesState<State = S>,
OT: ObserversTuple<S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
Z: UsesState<State = S>,
{
fn run_target(
@ -153,7 +153,7 @@ where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
{
#[inline]
fn observers(&self) -> &OT {
@ -171,7 +171,7 @@ where
H: FnMut(&<S as UsesInput>::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
S: HasExecutions + HasSolutions + HasCorpus + State,
{
/// Create a new in mem executor.
/// Caution: crash and restart in one of them will lead to odd behavior if multiple are used,
@ -190,6 +190,7 @@ where
Self: Executor<EM, Z, State = S>,
EM: EventFirer<State = S> + EventRestarter,
OF: Feedback<S>,
S: State,
Z: HasObjective<Objective = OF, State = S>,
{
let handlers = InProcessHandlers::new::<Self, EM, OF, Z>()?;
@ -255,7 +256,7 @@ where
H: FnMut(&<S as UsesInput>::Input) -> ExitKind + ?Sized,
HB: BorrowMut<H>,
OT: ObserversTuple<S>,
S: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
S: State + HasExecutions + HasSolutions + HasCorpus,
{
/// the timeout handler
#[inline]
@ -350,7 +351,7 @@ impl InProcessHandlers {
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
#[cfg(unix)]
@ -380,7 +381,7 @@ impl InProcessHandlers {
E: Executor<EM, Z> + HasObservers + HasInProcessHandlers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: State + HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
unsafe {
@ -591,7 +592,7 @@ pub fn run_observers_and_save_state<E, EM, OF, Z>(
E: HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
let observers = executor.observers_mut();
@ -657,7 +658,7 @@ pub mod unix_signal_handler {
feedbacks::Feedback,
fuzzer::HasObjective,
inputs::UsesInput,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions},
state::{HasCorpus, HasExecutions, HasSolutions},
};
pub(crate) type HandlerFuncPtr = unsafe fn(
@ -727,7 +728,7 @@ pub mod unix_signal_handler {
E: HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
let old_hook = panic::take_hook();
@ -775,7 +776,7 @@ pub mod unix_signal_handler {
E: HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
if !data.timeout_executor_ptr.is_null()
@ -825,7 +826,7 @@ pub mod unix_signal_handler {
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
@ -937,7 +938,7 @@ pub mod windows_asan_handler {
feedbacks::Feedback,
fuzzer::HasObjective,
inputs::UsesInput,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions},
state::{HasCorpus, HasExecutions, HasSolutions},
};
/// # Safety
@ -947,7 +948,7 @@ pub mod windows_asan_handler {
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
let data = &mut GLOBAL_STATE;
@ -1050,7 +1051,7 @@ pub mod windows_exception_handler {
feedbacks::Feedback,
fuzzer::HasObjective,
inputs::UsesInput,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions},
state::{HasCorpus, HasExecutions, HasSolutions, State},
};
pub(crate) type HandlerFuncPtr =
@ -1094,7 +1095,7 @@ pub mod windows_exception_handler {
E: HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
let old_hook = panic::take_hook();
@ -1158,7 +1159,7 @@ pub mod windows_exception_handler {
E: HasObservers + HasInProcessHandlers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: State + HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
let data: &mut InProcessExecutorHandlerData =
@ -1225,7 +1226,7 @@ pub mod windows_exception_handler {
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
// Have we set a timer_before?
@ -1645,7 +1646,7 @@ impl<'a, H, OT, S, SP> UsesState for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -1656,7 +1657,7 @@ impl<'a, H, OT, S, SP> UsesState for TimeoutInProcessForkExecutor<'a, H, OT, S,
where
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -1668,7 +1669,7 @@ where
EM: UsesState<State = S>,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
SP: ShMemProvider,
Z: UsesState<State = S>,
{
@ -1737,7 +1738,7 @@ where
EM: UsesState<State = S>,
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
SP: ShMemProvider,
Z: UsesState<State = S>,
{
@ -1841,7 +1842,7 @@ impl<'a, H, OT, S, SP> InProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
/// Creates a new [`InProcessForkExecutor`]
@ -1856,7 +1857,7 @@ where
where
EM: EventFirer<State = S> + EventRestarter,
OF: Feedback<S>,
S: HasSolutions + HasClientPerfMonitor,
S: HasSolutions,
Z: HasObjective<Objective = OF, State = S>,
{
let handlers = InChildProcessHandlers::new::<Self>()?;
@ -1886,7 +1887,7 @@ where
impl<'a, H, OT, S, SP> TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
SP: ShMemProvider,
{
@ -1904,7 +1905,7 @@ where
where
EM: EventFirer<State = S> + EventRestarter<State = S>,
OF: Feedback<S>,
S: HasSolutions + HasClientPerfMonitor,
S: HasSolutions,
Z: HasObjective<Objective = OF, State = S>,
{
let handlers = InChildProcessHandlers::with_timeout::<Self>()?;
@ -1946,7 +1947,7 @@ where
where
EM: EventFirer<State = S> + EventRestarter<State = S>,
OF: Feedback<S>,
S: HasSolutions + HasClientPerfMonitor,
S: HasSolutions,
Z: HasObjective<Objective = OF, State = S>,
{
let handlers = InChildProcessHandlers::with_timeout::<Self>()?;
@ -1992,7 +1993,7 @@ impl<'a, H, OT, S, SP> UsesObservers for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type Observers = OT;
@ -2003,7 +2004,7 @@ impl<'a, H, OT, S, SP> UsesObservers for TimeoutInProcessForkExecutor<'a, H, OT,
where
H: ?Sized + FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type Observers = OT;
@ -2013,7 +2014,7 @@ where
impl<'a, H, OT, S, SP> HasObservers for InProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
SP: ShMemProvider,
{
@ -2032,7 +2033,7 @@ where
impl<'a, H, OT, S, SP> HasObservers for TimeoutInProcessForkExecutor<'a, H, OT, S, SP>
where
H: FnMut(&S::Input) -> ExitKind + ?Sized,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
SP: ShMemProvider,
{

View File

@ -39,9 +39,9 @@ use libafl_bolts::AsSlice;
use serde::{Deserialize, Serialize};
use crate::{
inputs::{HasTargetBytes, UsesInput},
inputs::HasTargetBytes,
observers::{ObserversTuple, UsesObservers},
state::{HasExecutions, UsesState},
state::{HasExecutions, State, UsesState},
Error,
};
@ -158,7 +158,7 @@ struct NopExecutor<S> {
impl<S> UsesState for NopExecutor<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
@ -166,7 +166,7 @@ where
impl<EM, S, Z> Executor<EM, Z> for NopExecutor<S>
where
EM: UsesState<State = S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
S::Input: HasTargetBytes,
Z: UsesState<State = S>,
{

View File

@ -15,7 +15,7 @@ use crate::{
feedbacks::Feedback,
inputs::UsesInput,
observers::{concolic::ConcolicObserver, ObserversTuple},
state::{HasClientPerfMonitor, HasMetadata},
state::{HasMetadata, State},
Error,
};
@ -49,7 +49,7 @@ impl<S> Named for ConcolicFeedback<S> {
impl<S> Feedback<S> for ConcolicFeedback<S>
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(

View File

@ -16,7 +16,7 @@ use crate::{
feedbacks::Feedback,
inputs::Input,
observers::{Observer, ObserversTuple},
state::{HasClientPerfMonitor, HasMetadata, State},
state::{HasMetadata, State},
Error,
};
@ -119,7 +119,7 @@ impl<F, I, O1, O2, S> Feedback<S> for DiffFeedback<F, I, O1, O2, S>
where
F: FnMut(&O1, &O2) -> DiffResult,
I: Input,
S: HasMetadata + HasClientPerfMonitor + State<Input = I>,
S: HasMetadata + State<Input = I>,
O1: Observer<S> + PartialEq<O2>,
O2: Observer<S>,
{
@ -163,7 +163,7 @@ mod tests {
feedbacks::{differential::DiffResult, DiffFeedback, Feedback},
inputs::{BytesInput, UsesInput},
observers::Observer,
state::{NopState, UsesState},
state::{NopState, State, UsesState},
};
#[derive(Debug)]
@ -196,13 +196,13 @@ mod tests {
}
impl<S> UsesState for NopEventFirer<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S> EventFirer for NopEventFirer<S>
where
S: UsesInput,
S: State,
{
fn fire(
&mut self,

View File

@ -24,7 +24,7 @@ use crate::{
inputs::UsesInput,
monitors::UserStats,
observers::{MapObserver, Observer, ObserversTuple, UsesObserver},
state::{HasClientPerfMonitor, HasMetadata, HasNamedMetadata},
state::{HasMetadata, HasNamedMetadata, State},
Error,
};
@ -395,7 +395,7 @@ where
N: IsNovel<T>,
O: MapObserver<Entry = T> + for<'it> AsIter<'it, Item = T>,
R: Reducer<T>,
S: UsesInput + HasClientPerfMonitor + HasNamedMetadata,
S: State + HasNamedMetadata,
T: Default + Copy + Serialize + for<'de> Deserialize<'de> + PartialEq + Debug + 'static,
{
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
@ -496,7 +496,7 @@ impl<O, S> Feedback<S> for MapFeedback<DifferentIsNovel, O, MaxReducer, S, u8>
where
O: MapObserver<Entry = u8> + AsSlice<Entry = u8>,
for<'it> O: AsIter<'it, Item = u8>,
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor,
S: State + HasNamedMetadata,
{
#[allow(clippy::wrong_self_convention)]
#[allow(clippy::needless_range_loop)]
@ -664,7 +664,7 @@ where
O: MapObserver<Entry = T>,
for<'it> O: AsIter<'it, Item = T>,
N: IsNovel<T>,
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor,
S: UsesInput + HasNamedMetadata,
{
/// Create new `MapFeedback`
#[must_use]
@ -875,7 +875,7 @@ where
impl<O, S> Feedback<S> for ReachabilityFeedback<O, S>
where
S: UsesInput + HasClientPerfMonitor,
S: State,
O: MapObserver<Entry = usize>,
for<'it> O: AsIter<'it, Item = usize>,
{

View File

@ -38,9 +38,8 @@ use crate::{
corpus::Testcase,
events::EventFirer,
executors::ExitKind,
inputs::UsesInput,
observers::{ListObserver, ObserversTuple, TimeObserver},
state::HasClientPerfMonitor,
state::State,
Error,
};
@ -49,7 +48,7 @@ use crate::{
/// indicating the "interestingness" of the last run.
pub trait Feedback<S>: Named
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// Initializes the feedback state.
/// This method is called after that the `State` is created.
@ -140,7 +139,7 @@ where
A: Feedback<S>,
B: Feedback<S>,
FL: FeedbackLogic<A, B, S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// First [`Feedback`]
pub first: A,
@ -155,7 +154,7 @@ where
A: Feedback<S>,
B: Feedback<S>,
FL: FeedbackLogic<A, B, S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn name(&self) -> &str {
self.name.as_ref()
@ -167,7 +166,7 @@ where
A: Feedback<S>,
B: Feedback<S>,
FL: FeedbackLogic<A, B, S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// Create a new combined feedback
pub fn new(first: A, second: B) -> Self {
@ -186,7 +185,7 @@ where
A: Feedback<S>,
B: Feedback<S>,
FL: FeedbackLogic<A, B, S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
self.first.init_state(state)?;
@ -269,7 +268,7 @@ pub trait FeedbackLogic<A, B, S>: 'static
where
A: Feedback<S>,
B: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// The name of this combination
fn name() -> &'static str;
@ -310,7 +309,7 @@ where
pub trait FeedbackFactory<F, S, T>
where
F: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// Create the feedback from the provided context
fn create_feedback(&self, ctx: &T) -> F;
@ -320,7 +319,7 @@ impl<FE, FU, S, T> FeedbackFactory<FE, S, T> for FU
where
FU: Fn(&T) -> FE,
FE: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn create_feedback(&self, ctx: &T) -> FE {
self(ctx)
@ -350,7 +349,7 @@ where
impl<F, S, T> FeedbackFactory<F, S, T> for DefaultFeedbackFactory<F>
where
F: Feedback<S> + Default,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn create_feedback(&self, _ctx: &T) -> F {
F::default()
@ -377,7 +376,7 @@ impl<A, B, S> FeedbackLogic<A, B, S> for LogicEagerOr
where
A: Feedback<S>,
B: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn name() -> &'static str {
"Eager OR"
@ -427,7 +426,7 @@ impl<A, B, S> FeedbackLogic<A, B, S> for LogicFastOr
where
A: Feedback<S>,
B: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn name() -> &'static str {
"Fast OR"
@ -483,7 +482,7 @@ impl<A, B, S> FeedbackLogic<A, B, S> for LogicEagerAnd
where
A: Feedback<S>,
B: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn name() -> &'static str {
"Eager AND"
@ -533,7 +532,7 @@ impl<A, B, S> FeedbackLogic<A, B, S> for LogicFastAnd
where
A: Feedback<S>,
B: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn name() -> &'static str {
"Fast AND"
@ -608,7 +607,7 @@ pub type FastOrFeedback<A, B, S> = CombinedFeedback<A, B, LogicFastOr, S>;
pub struct NotFeedback<A, S>
where
A: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// The feedback to invert
pub first: A,
@ -620,7 +619,7 @@ where
impl<A, S> Debug for NotFeedback<A, S>
where
A: Feedback<S> + Debug,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.debug_struct("NotFeedback")
@ -633,7 +632,7 @@ where
impl<A, S> Feedback<S> for NotFeedback<A, S>
where
A: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
self.first.init_state(state)
@ -679,7 +678,7 @@ where
impl<A, S> Named for NotFeedback<A, S>
where
A: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[inline]
fn name(&self) -> &str {
@ -690,7 +689,7 @@ where
impl<A, S> NotFeedback<A, S>
where
A: Feedback<S>,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
/// Creates a new [`NotFeedback`].
pub fn new(first: A) -> Self {
@ -758,7 +757,7 @@ macro_rules! feedback_not {
/// Hack to use () as empty Feedback
impl<S> Feedback<S> for ()
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
@ -783,7 +782,7 @@ pub struct CrashFeedback {}
impl<S> Feedback<S> for CrashFeedback
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
@ -836,7 +835,7 @@ pub struct TimeoutFeedback {}
impl<S> Feedback<S> for TimeoutFeedback
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
@ -893,7 +892,7 @@ pub struct TimeFeedback {
impl<S> Feedback<S> for TimeFeedback
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
@ -973,7 +972,7 @@ where
impl<S, T> Feedback<S> for ListFeedback<T>
where
S: UsesInput + HasClientPerfMonitor,
S: State,
T: Debug + Serialize + serde::de::DeserializeOwned,
{
#[allow(clippy::wrong_self_convention)]
@ -1045,7 +1044,7 @@ pub enum ConstFeedback {
impl<S> Feedback<S> for ConstFeedback
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
#[inline]
#[allow(clippy::wrong_self_convention)]

View File

@ -14,9 +14,9 @@ use crate::{
executors::ExitKind,
feedbacks::Feedback,
generators::NautilusContext,
inputs::{NautilusInput, UsesInput},
inputs::NautilusInput,
observers::ObserversTuple,
state::{HasClientPerfMonitor, HasCorpus, HasMetadata},
state::{HasCorpus, HasMetadata, State},
Error,
};
@ -82,10 +82,7 @@ impl<'a, S> Named for NautilusFeedback<'a, S> {
impl<'a, S> Feedback<S> for NautilusFeedback<'a, S>
where
S: HasMetadata
+ HasClientPerfMonitor
+ UsesInput<Input = NautilusInput>
+ HasCorpus<Input = NautilusInput>,
S: HasMetadata + HasCorpus<Input = NautilusInput> + State<Input = NautilusInput>,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(

View File

@ -13,7 +13,7 @@ use crate::{
feedbacks::{Feedback, HasObserverName},
inputs::UsesInput,
observers::{ObserverWithHashField, ObserversTuple},
state::{HasClientPerfMonitor, HasNamedMetadata},
state::{HasNamedMetadata, State},
Error,
};
@ -88,7 +88,7 @@ pub struct NewHashFeedback<O, S> {
impl<O, S> Feedback<S> for NewHashFeedback<O, S>
where
O: ObserverWithHashField + Named,
S: UsesInput + HasNamedMetadata + HasClientPerfMonitor,
S: State + HasNamedMetadata,
{
fn init_state(&mut self, state: &mut S) -> Result<(), Error> {
state.add_named_metadata(

View File

@ -8,8 +8,6 @@ use serde::{de::DeserializeOwned, Serialize};
#[cfg(test)]
use crate::inputs::Input;
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
#[cfg(test)]
use crate::state::NopState;
use crate::{
@ -24,11 +22,13 @@ use crate::{
stages::StagesTuple,
start_timer,
state::{
HasClientPerfMonitor, HasCorpus, HasExecutions, HasImported, HasLastReportTime,
HasMetadata, HasSolutions, UsesState,
HasCorpus, HasExecutions, HasImported, HasLastReportTime, HasMetadata, HasSolutions,
UsesState,
},
Error,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
/// Send a monitor update all 15 (or more) seconds
const STATS_TIMEOUT_DEFAULT: Duration = Duration::from_secs(15);
@ -49,10 +49,7 @@ where
}
/// Holds an feedback
pub trait HasFeedback: UsesState
where
Self::State: HasClientPerfMonitor,
{
pub trait HasFeedback: UsesState {
/// The feedback type
type Feedback: Feedback<Self::State>;
@ -64,10 +61,7 @@ where
}
/// Holds an objective feedback
pub trait HasObjective: UsesState
where
Self::State: HasClientPerfMonitor,
{
pub trait HasObjective: UsesState {
/// The type of the [`Feedback`] used to find objectives for this fuzzer
type Objective: Feedback<Self::State>;
@ -158,7 +152,7 @@ where
/// The main fuzzer trait.
pub trait Fuzzer<E, EM, ST>: Sized + UsesState
where
Self::State: HasClientPerfMonitor + HasMetadata + HasExecutions + HasLastReportTime,
Self::State: HasMetadata + HasExecutions + HasLastReportTime,
E: UsesState<State = Self::State>,
EM: ProgressReporter<State = Self::State>,
ST: StagesTuple<E, EM, Self::State, Self>,
@ -255,7 +249,7 @@ where
CS: Scheduler,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus,
CS::State: HasCorpus,
{
scheduler: CS,
feedback: F,
@ -268,7 +262,7 @@ where
CS: Scheduler,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus,
CS::State: HasCorpus,
{
type State = CS::State;
}
@ -278,7 +272,7 @@ where
CS: Scheduler,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus,
CS::State: HasCorpus,
{
type Scheduler = CS;
@ -296,7 +290,7 @@ where
CS: Scheduler,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus,
CS::State: HasCorpus,
{
type Feedback = F;
@ -314,7 +308,7 @@ where
CS: Scheduler,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus,
CS::State: HasCorpus,
{
type Objective = OF;
@ -333,8 +327,7 @@ where
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
OT: ObserversTuple<CS::State> + Serialize + DeserializeOwned,
CS::State:
HasCorpus + HasSolutions + HasClientPerfMonitor + HasExecutions + HasCorpus + HasImported,
CS::State: HasCorpus + HasSolutions + HasExecutions + HasCorpus + HasImported,
{
/// Evaluate if a set of observation channels has an interesting state
fn process_execution<EM>(
@ -454,7 +447,7 @@ where
OT: ObserversTuple<CS::State> + Serialize + DeserializeOwned,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasCorpus + HasSolutions + HasClientPerfMonitor + HasExecutions + HasImported,
CS::State: HasCorpus + HasSolutions + HasExecutions + HasImported,
{
/// Process one input, adding to the respective corpora if needed and firing the right events
#[inline]
@ -487,7 +480,7 @@ where
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
OT: ObserversTuple<CS::State> + Serialize + DeserializeOwned,
CS::State: HasCorpus + HasSolutions + HasClientPerfMonitor + HasExecutions + HasImported,
CS::State: HasCorpus + HasSolutions + HasExecutions + HasImported,
{
/// Process one input, adding to the respective corpora if needed and firing the right events
#[inline]
@ -590,13 +583,8 @@ where
EM: ProgressReporter + EventProcessor<E, Self, State = CS::State>,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: HasClientPerfMonitor
+ HasExecutions
+ HasMetadata
+ HasCorpus
+ HasTestcase
+ HasImported
+ HasLastReportTime,
CS::State:
HasExecutions + HasMetadata + HasCorpus + HasTestcase + HasImported + HasLastReportTime,
ST: StagesTuple<E, EM, CS::State, Self>,
{
fn fuzz_one(
@ -650,7 +638,7 @@ where
CS: Scheduler,
F: Feedback<CS::State>,
OF: Feedback<CS::State>,
CS::State: UsesInput + HasExecutions + HasClientPerfMonitor + HasCorpus,
CS::State: UsesInput + HasExecutions + HasCorpus,
{
/// Create a new `StdFuzzer` with standard behavior.
pub fn new(scheduler: CS, feedback: F, objective: OF) -> Self {
@ -716,7 +704,7 @@ where
OF: Feedback<CS::State>,
E: Executor<EM, Self> + HasObservers<State = CS::State>,
EM: UsesState<State = CS::State>,
CS::State: UsesInput + HasExecutions + HasClientPerfMonitor + HasCorpus,
CS::State: UsesInput + HasExecutions + HasCorpus,
{
/// Runs the input and triggers observers and feedback
fn execute_input(

View File

@ -611,6 +611,26 @@ pub struct ClientPerfMonitor {
timer_start: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
/// Count the imported testcase from other nodes that came with observers
pub struct ScalabilityMonitor {
/// Imported testcase received with observer
pub testcase_with_observers: usize,
/// Imported testcase received without observer
pub testcase_without_observers: usize,
}
impl ScalabilityMonitor {
/// Constructor
#[must_use]
pub fn new() -> Self {
Self {
testcase_with_observers: 0,
testcase_without_observers: 0,
}
}
}
/// Various features that are measured for performance
#[derive(Serialize, Deserialize, Debug, Clone)]
#[repr(u8)]

View File

@ -8,10 +8,9 @@ use serde::{Deserialize, Serialize};
use crate::{
corpus::{Corpus, CorpusId, HasTestcase, SchedulerTestcaseMetadata, Testcase},
inputs::UsesInput,
observers::{MapObserver, ObserversTuple},
schedulers::{powersched::SchedulerMetadata, testcase_score::TestcaseScore, Scheduler},
state::{HasCorpus, HasExecutions, HasMetadata, HasRand, UsesState},
state::{HasCorpus, HasExecutions, HasMetadata, HasRand, State, UsesState},
Error,
};
@ -205,14 +204,14 @@ where
impl<O, S> UsesState for EcoScheduler<O, S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<O, S> Scheduler for EcoScheduler<O, S>
where
S: HasCorpus + HasMetadata + HasRand + HasExecutions + HasTestcase,
S: HasCorpus + HasMetadata + HasRand + HasExecutions + HasTestcase + State,
O: MapObserver,
{
/// Called when a [`Testcase`] is added to the corpus

View File

@ -38,7 +38,7 @@ use crate::{
inputs::UsesInput,
observers::ObserversTuple,
random_corpus_id,
state::{HasCorpus, HasRand, UsesState},
state::{HasCorpus, HasRand, State, UsesState},
Error,
};
@ -114,14 +114,14 @@ pub struct RandScheduler<S> {
impl<S> UsesState for RandScheduler<S>
where
S: UsesInput + HasTestcase,
S: State + HasTestcase,
{
type State = S;
}
impl<S> Scheduler for RandScheduler<S>
where
S: HasCorpus + HasRand + HasTestcase,
S: HasCorpus + HasRand + HasTestcase + State,
{
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
// Set parent id

View File

@ -13,7 +13,7 @@ use crate::{
inputs::UsesInput,
observers::{MapObserver, ObserversTuple},
schedulers::{RemovableScheduler, Scheduler},
state::{HasCorpus, HasMetadata, UsesState},
state::{HasCorpus, HasMetadata, State, UsesState},
Error,
};
@ -177,14 +177,14 @@ pub struct PowerQueueScheduler<O, S> {
impl<O, S> UsesState for PowerQueueScheduler<O, S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<O, S> RemovableScheduler for PowerQueueScheduler<O, S>
where
S: HasCorpus + HasMetadata + HasTestcase,
S: HasCorpus + HasMetadata + HasTestcase + State,
O: MapObserver,
{
#[allow(clippy::cast_precision_loss)]
@ -253,7 +253,7 @@ where
impl<O, S> Scheduler for PowerQueueScheduler<O, S>
where
S: HasCorpus + HasMetadata + HasTestcase,
S: HasCorpus + HasMetadata + HasTestcase + State,
O: MapObserver,
{
/// Called when a [`Testcase`] is added to the corpus

View File

@ -12,7 +12,7 @@ use crate::{
corpus::{Corpus, CorpusId, HasTestcase},
inputs::UsesInput,
schedulers::{Scheduler, TestcaseScore},
state::{HasCorpus, HasMetadata, HasRand, UsesState},
state::{HasCorpus, HasMetadata, HasRand, State, UsesState},
Error,
};
@ -93,7 +93,7 @@ where
impl<F, S> UsesState for ProbabilitySamplingScheduler<F, S>
where
S: UsesInput + HasTestcase,
S: State + HasTestcase,
{
type State = S;
}
@ -101,7 +101,7 @@ where
impl<F, S> Scheduler for ProbabilitySamplingScheduler<F, S>
where
F: TestcaseScore<S>,
S: HasCorpus + HasMetadata + HasRand + HasTestcase,
S: HasCorpus + HasMetadata + HasRand + HasTestcase + State,
{
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
let current_idx = *state.corpus().current();

View File

@ -5,9 +5,8 @@ use core::marker::PhantomData;
use crate::{
corpus::{Corpus, CorpusId, HasTestcase},
inputs::UsesInput,
schedulers::{RemovableScheduler, Scheduler},
state::{HasCorpus, UsesState},
state::{HasCorpus, State, UsesState},
Error,
};
@ -19,16 +18,16 @@ pub struct QueueScheduler<S> {
impl<S> UsesState for QueueScheduler<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S> RemovableScheduler for QueueScheduler<S> where S: HasCorpus + HasTestcase {}
impl<S> RemovableScheduler for QueueScheduler<S> where S: HasCorpus + HasTestcase + State {}
impl<S> Scheduler for QueueScheduler<S>
where
S: HasCorpus + HasTestcase,
S: HasCorpus + HasTestcase + State,
{
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
// Set parent id

View File

@ -11,9 +11,8 @@ use serde::{Deserialize, Serialize};
use super::RemovableScheduler;
use crate::{
corpus::{Corpus, CorpusId, HasTestcase},
inputs::UsesInput,
schedulers::Scheduler,
state::{HasCorpus, HasMetadata, UsesState},
state::{HasCorpus, HasMetadata, State, UsesState},
Error,
};
@ -91,16 +90,19 @@ where
impl<S> UsesState for TuneableScheduler<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S> RemovableScheduler for TuneableScheduler<S> where S: HasCorpus + HasMetadata + HasTestcase {}
impl<S> RemovableScheduler for TuneableScheduler<S> where
S: HasCorpus + HasMetadata + HasTestcase + State
{
}
impl<S> Scheduler for TuneableScheduler<S>
where
S: HasCorpus + HasMetadata + HasTestcase,
S: HasCorpus + HasMetadata + HasTestcase + State,
{
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
// Set parent id

View File

@ -20,7 +20,7 @@ use crate::{
testcase_score::{CorpusWeightTestcaseScore, TestcaseScore},
RemovableScheduler, Scheduler,
},
state::{HasCorpus, HasMetadata, HasRand, UsesState},
state::{HasCorpus, HasMetadata, HasRand, State, UsesState},
Error,
};
@ -224,7 +224,7 @@ where
impl<F, O, S> UsesState for WeightedScheduler<F, O, S>
where
S: UsesInput,
S: State,
{
type State = S;
}
@ -233,7 +233,7 @@ impl<F, O, S> RemovableScheduler for WeightedScheduler<F, O, S>
where
F: TestcaseScore<S>,
O: MapObserver,
S: HasCorpus + HasMetadata + HasRand + HasTestcase,
S: HasCorpus + HasMetadata + HasRand + HasTestcase + State,
{
#[allow(clippy::cast_precision_loss)]
fn on_remove(
@ -305,7 +305,7 @@ impl<F, O, S> Scheduler for WeightedScheduler<F, O, S>
where
F: TestcaseScore<S>,
O: MapObserver,
S: HasCorpus + HasMetadata + HasRand + HasTestcase,
S: HasCorpus + HasMetadata + HasRand + HasTestcase + State,
{
/// Called when a [`Testcase`] is added to the corpus
fn on_add(&mut self, state: &mut S, idx: CorpusId) -> Result<(), Error> {

View File

@ -17,14 +17,11 @@ use crate::{
executors::{Executor, ExitKind, HasObservers},
feedbacks::{map::MapFeedbackMetadata, HasObserverName},
fuzzer::Evaluator,
inputs::UsesInput,
monitors::UserStats,
observers::{MapObserver, ObserversTuple, UsesObserver},
schedulers::powersched::SchedulerMetadata,
stages::Stage,
state::{
HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata, HasNamedMetadata, UsesState,
},
state::{HasCorpus, HasExecutions, HasMetadata, HasNamedMetadata, State, UsesState},
Error,
};
@ -80,7 +77,7 @@ const CAL_STAGE_MAX: usize = 8; // AFL++'s CAL_CYCLES + 1
impl<O, OT, S> UsesState for CalibrationStage<O, OT, S>
where
S: UsesInput,
S: State,
{
type State = S;
}
@ -92,7 +89,7 @@ where
O: MapObserver,
for<'de> <O as MapObserver>::Entry: Serialize + Deserialize<'de> + 'static,
OT: ObserversTuple<E::State>,
E::State: HasCorpus + HasMetadata + HasClientPerfMonitor + HasNamedMetadata + HasExecutions,
E::State: HasCorpus + HasMetadata + HasNamedMetadata + HasExecutions,
Z: Evaluator<E, EM, State = E::State>,
{
#[inline]

View File

@ -8,11 +8,15 @@ use alloc::{borrow::ToOwned, string::ToString, vec::Vec};
use core::marker::PhantomData;
use super::{Stage, TracingStage};
#[cfg(feature = "introspection")]
use crate::state::HasClientPerfMonitor;
#[cfg(feature = "concolic_mutation")]
use crate::state::State;
use crate::{
corpus::{Corpus, CorpusId},
executors::{Executor, HasObservers},
observers::concolic::ConcolicObserver,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata},
state::{HasCorpus, HasExecutions, HasMetadata},
Error,
};
@ -35,7 +39,7 @@ where
E: UsesState<State = TE::State>,
EM: UsesState<State = TE::State>,
TE: Executor<EM, Z> + HasObservers,
TE::State: HasClientPerfMonitor + HasExecutions + HasCorpus,
TE::State: HasExecutions + HasCorpus,
Z: UsesState<State = TE::State>,
{
#[inline]
@ -354,7 +358,7 @@ where
EM: UsesState<State = Z::State>,
Z: Evaluator<E, EM>,
Z::Input: HasBytesVec,
Z::State: HasClientPerfMonitor + HasExecutions + HasCorpus,
Z::State: State + HasExecutions + HasCorpus,
{
#[inline]
fn perform(

View File

@ -8,8 +8,6 @@ use core::{fmt::Debug, marker::PhantomData};
use libafl_bolts::AsSlice;
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
corpus::{Corpus, CorpusId},
executors::{Executor, HasObservers},
@ -19,9 +17,11 @@ use crate::{
observers::{MapObserver, ObserversTuple},
stages::Stage,
start_timer,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata, UsesState},
state::{HasCorpus, HasExecutions, HasMetadata, UsesState},
Error,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
const MAX_GENERALIZED_LEN: usize = 8192;
@ -60,11 +60,7 @@ where
O: MapObserver,
E: Executor<EM, Z> + HasObservers,
E::Observers: ObserversTuple<E::State>,
E::State: UsesInput<Input = BytesInput>
+ HasClientPerfMonitor
+ HasExecutions
+ HasMetadata
+ HasCorpus,
E::State: UsesInput<Input = BytesInput> + HasExecutions + HasMetadata + HasCorpus,
EM: UsesState<State = E::State>,
Z: UsesState<State = E::State>,
{
@ -316,11 +312,7 @@ where
EM: UsesState,
O: MapObserver,
OT: ObserversTuple<EM::State>,
EM::State: UsesInput<Input = BytesInput>
+ HasClientPerfMonitor
+ HasExecutions
+ HasMetadata
+ HasCorpus,
EM::State: UsesInput<Input = BytesInput> + HasExecutions + HasMetadata + HasCorpus,
{
/// Create a new [`GeneralizationStage`].
#[must_use]

View File

@ -75,10 +75,7 @@ use crate::{
inputs::UsesInput,
observers::ObserversTuple,
schedulers::Scheduler,
state::{
HasClientPerfMonitor, HasCorpus, HasExecutions, HasLastReportTime, HasMetadata, HasRand,
UsesState,
},
state::{HasCorpus, HasExecutions, HasLastReportTime, HasMetadata, HasRand, UsesState},
Error, EvaluatorObservers, ExecutesInput, ExecutionProcessor, HasScheduler,
};
@ -260,12 +257,7 @@ where
impl<CS, E, EM, OT, PS, Z> Stage<E, EM, Z> for PushStageAdapter<CS, EM, OT, PS, Z>
where
CS: Scheduler,
CS::State: HasClientPerfMonitor
+ HasExecutions
+ HasMetadata
+ HasRand
+ HasCorpus
+ HasLastReportTime,
CS::State: HasExecutions + HasMetadata + HasRand + HasCorpus + HasLastReportTime,
E: Executor<EM, Z> + HasObservers<Observers = OT, State = CS::State>,
EM: EventFirer<State = CS::State>
+ EventRestarter

View File

@ -5,8 +5,6 @@ use core::marker::PhantomData;
use libafl_bolts::rands::Rand;
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
corpus::{Corpus, CorpusId, Testcase},
fuzzer::Evaluator,
@ -15,9 +13,11 @@ use crate::{
mutators::{MultiMutator, MutationResult, Mutator},
stages::Stage,
start_timer,
state::{HasClientPerfMonitor, HasCorpus, HasRand, UsesState},
state::{HasCorpus, HasRand, UsesState},
Error,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
// TODO multi mutators stage
@ -94,7 +94,7 @@ where
M: Mutator<I, Self::State>,
EM: UsesState<State = Self::State>,
Z: Evaluator<E, EM, State = Self::State>,
Self::State: HasClientPerfMonitor + HasCorpus,
Self::State: HasCorpus,
I: MutatedTransform<Self::Input, Self::State> + Clone,
{
/// The mutator registered for this stage
@ -170,7 +170,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
I: MutatedTransform<Self::Input, Self::State> + Clone,
{
/// The mutator, added to this stage
@ -197,7 +197,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
{
type State = Z::State;
}
@ -208,7 +208,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
I: MutatedTransform<Self::Input, Self::State> + Clone,
{
#[inline]
@ -236,7 +236,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<Z::Input, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
{
/// Creates a new default mutational stage
pub fn new(mutator: M) -> Self {
@ -255,7 +255,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
{
/// Creates a new transforming mutational stage with the default max iterations
pub fn transforming(mutator: M) -> Self {
@ -286,7 +286,7 @@ where
EM: UsesState<State = Z::State>,
M: MultiMutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
{
type State = Z::State;
}
@ -297,7 +297,7 @@ where
EM: UsesState<State = Z::State>,
M: MultiMutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
I: MutatedTransform<Self::Input, Self::State> + Clone,
{
#[inline]
@ -338,7 +338,7 @@ where
EM: UsesState<State = Z::State>,
M: MultiMutator<Z::Input, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
{
/// Creates a new default mutational stage
pub fn new(mutator: M) -> Self {
@ -352,7 +352,7 @@ where
EM: UsesState<State = Z::State>,
M: MultiMutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
{
/// Creates a new transforming mutational stage
pub fn transforming(mutator: M) -> Self {

View File

@ -11,7 +11,7 @@ use crate::{
ecofuzz::EcoTestcaseScore, testcase_score::CorpusPowerTestcaseScore, TestcaseScore,
},
stages::{mutational::MutatedTransform, MutationalStage, Stage},
state::{HasClientPerfMonitor, HasCorpus, HasMetadata, HasRand, UsesState},
state::{HasCorpus, HasMetadata, HasRand, UsesState},
Error,
};
@ -36,7 +36,7 @@ where
EM: UsesState<State = E::State>,
F: TestcaseScore<E::State>,
M: Mutator<I, E::State>,
E::State: HasClientPerfMonitor + HasCorpus + HasMetadata + HasRand,
E::State: HasCorpus + HasMetadata + HasRand,
Z: Evaluator<E, EM, State = E::State>,
I: MutatedTransform<E::Input, E::State> + Clone,
{
@ -69,7 +69,7 @@ where
EM: UsesState<State = E::State>,
F: TestcaseScore<E::State>,
M: Mutator<I, E::State>,
E::State: HasClientPerfMonitor + HasCorpus + HasMetadata + HasRand,
E::State: HasCorpus + HasMetadata + HasRand,
Z: Evaluator<E, EM, State = E::State>,
I: MutatedTransform<E::Input, E::State> + Clone,
{
@ -94,7 +94,7 @@ where
EM: UsesState<State = E::State>,
F: TestcaseScore<E::State>,
M: Mutator<E::Input, E::State>,
E::State: HasClientPerfMonitor + HasCorpus + HasMetadata + HasRand,
E::State: HasCorpus + HasMetadata + HasRand,
Z: Evaluator<E, EM, State = E::State>,
{
/// Creates a new [`PowerMutationalStage`]
@ -109,7 +109,7 @@ where
EM: UsesState<State = E::State>,
F: TestcaseScore<E::State>,
M: Mutator<I, E::State>,
E::State: HasClientPerfMonitor + HasCorpus + HasMetadata + HasRand,
E::State: HasCorpus + HasMetadata + HasRand,
Z: Evaluator<E, EM, State = E::State>,
{
/// Creates a new transforming [`PowerMutationalStage`]

View File

@ -22,9 +22,7 @@ use crate::{
inputs::UsesInput,
observers::ObserversTuple,
schedulers::Scheduler,
state::{
HasClientPerfMonitor, HasCorpus, HasExecutions, HasLastReportTime, HasMetadata, HasRand,
},
state::{HasCorpus, HasExecutions, HasLastReportTime, HasMetadata, HasRand},
Error, EvaluatorObservers, ExecutionProcessor, HasScheduler,
};
@ -39,7 +37,7 @@ where
CS: Scheduler,
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasRand + HasCorpus,
CS::State: HasRand + HasCorpus,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -60,7 +58,7 @@ where
CS: Scheduler,
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasRand + HasCorpus,
CS::State: HasRand + HasCorpus,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -85,7 +83,7 @@ where
CS: Scheduler,
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasRand + HasCorpus,
CS::State: HasRand + HasCorpus,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -115,7 +113,7 @@ where
CS: Scheduler,
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasRand + HasCorpus,
CS::State: HasRand + HasCorpus,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -182,12 +180,7 @@ where
pub trait PushStage<CS, EM, OT, Z>: Iterator
where
CS: Scheduler,
CS::State: HasClientPerfMonitor
+ HasRand
+ HasExecutions
+ HasMetadata
+ HasCorpus
+ HasLastReportTime,
CS::State: HasRand + HasExecutions + HasMetadata + HasCorpus + HasLastReportTime,
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId + ProgressReporter,
OT: ObserversTuple<CS::State>,
Z: ExecutionProcessor<OT, State = CS::State>

View File

@ -10,8 +10,6 @@ use core::{
use libafl_bolts::rands::Rand;
use super::{PushStage, PushStageHelper, PushStageSharedState};
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
corpus::{Corpus, CorpusId},
events::{EventFirer, EventRestarter, HasEventManagerId, ProgressReporter},
@ -22,11 +20,11 @@ use crate::{
observers::ObserversTuple,
schedulers::Scheduler,
start_timer,
state::{
HasClientPerfMonitor, HasCorpus, HasExecutions, HasLastReportTime, HasMetadata, HasRand,
},
state::{HasCorpus, HasExecutions, HasLastReportTime, HasMetadata, HasRand},
Error, EvaluatorObservers, ExecutionProcessor, HasScheduler,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
/// The default maximum number of mutations to perform per input.
pub static DEFAULT_MUTATIONAL_MAX_ITERATIONS: u64 = 128;
@ -46,7 +44,7 @@ where
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
M: Mutator<CS::Input, CS::State>,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasRand + HasCorpus + Clone + Debug,
CS::State: HasRand + HasCorpus + Clone + Debug,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -68,7 +66,7 @@ where
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
M: Mutator<CS::Input, CS::State>,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus + HasRand + Clone + Debug,
CS::State: HasCorpus + HasRand + Clone + Debug,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -91,14 +89,8 @@ where
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId + ProgressReporter,
M: Mutator<CS::Input, CS::State>,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor
+ HasCorpus
+ HasRand
+ HasExecutions
+ HasLastReportTime
+ HasMetadata
+ Clone
+ Debug,
CS::State:
HasCorpus + HasRand + HasExecutions + HasLastReportTime + HasMetadata + Clone + Debug,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -211,14 +203,8 @@ where
EM: EventFirer + EventRestarter + HasEventManagerId + ProgressReporter<State = CS::State>,
M: Mutator<CS::Input, CS::State>,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor
+ HasCorpus
+ HasRand
+ HasExecutions
+ HasMetadata
+ HasLastReportTime
+ Clone
+ Debug,
CS::State:
HasCorpus + HasRand + HasExecutions + HasMetadata + HasLastReportTime + Clone + Debug,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,
@ -236,7 +222,7 @@ where
EM: EventFirer<State = CS::State> + EventRestarter + HasEventManagerId,
M: Mutator<CS::Input, CS::State>,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus + HasRand + Clone + Debug,
CS::State: HasCorpus + HasRand + Clone + Debug,
Z: ExecutionProcessor<OT, State = CS::State>
+ EvaluatorObservers<OT>
+ HasScheduler<Scheduler = CS>,

View File

@ -9,9 +9,9 @@ use serde::{Deserialize, Serialize};
use crate::{
corpus::{CorpusId, HasTestcase},
inputs::{BytesInput, HasBytesVec, UsesInput},
inputs::{BytesInput, HasBytesVec},
stages::Stage,
state::{HasCorpus, HasMetadata, UsesState},
state::{HasCorpus, HasMetadata, State, UsesState},
};
/// Metadata which stores the list of pre-computed string-like ranges in the input
@ -92,14 +92,14 @@ impl<S> StringIdentificationStage<S> {
impl<S> UsesState for StringIdentificationStage<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S, E, EM, Z> Stage<E, EM, Z> for StringIdentificationStage<S>
where
S: HasTestcase<Input = BytesInput> + HasCorpus,
S: HasTestcase<Input = BytesInput> + HasCorpus + State,
E: UsesState<State = S>,
EM: UsesState<State = S>,
Z: UsesState<State = S>,

View File

@ -10,6 +10,8 @@ use std::{
use libafl_bolts::{current_time, shmem::ShMemProvider};
use serde::{Deserialize, Serialize};
#[cfg(feature = "introspection")]
use crate::state::HasClientPerfMonitor;
use crate::{
corpus::{Corpus, CorpusId, HasTestcase},
events::{llmp::LlmpEventConverter, Event, EventConfig, EventFirer},
@ -17,7 +19,7 @@ use crate::{
fuzzer::{Evaluator, EvaluatorObservers, ExecutionProcessor},
inputs::{Input, InputConverter, UsesInput},
stages::Stage,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata, HasRand, UsesState},
state::{HasCorpus, HasExecutions, HasMetadata, HasRand, State, UsesState},
Error,
};
@ -63,7 +65,7 @@ where
E: UsesState<State = Z::State>,
EM: UsesState<State = Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasMetadata,
Z::State: HasCorpus + HasRand + HasMetadata,
{
#[inline]
fn perform(
@ -108,7 +110,7 @@ where
E: UsesState<State = Z::State>,
EM: UsesState<State = Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasMetadata,
Z::State: HasCorpus + HasRand + HasMetadata,
{
/// Creates a new [`SyncFromDiskStage`]
#[must_use]
@ -174,7 +176,7 @@ where
E: UsesState<State = Z::State>,
EM: UsesState<State = Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasMetadata,
Z::State: HasCorpus + HasRand + HasMetadata,
{
/// Creates a new [`SyncFromDiskStage`] invoking `Input::from_file` to load inputs
#[must_use]
@ -231,7 +233,7 @@ where
impl<IC, ICB, DI, S, SP> UsesState for SyncFromBrokerStage<IC, ICB, DI, S, SP>
where
SP: ShMemProvider + 'static,
S: UsesInput,
S: State,
IC: InputConverter<From = S::Input, To = DI>,
ICB: InputConverter<From = DI, To = S::Input>,
DI: Input,
@ -242,13 +244,7 @@ where
impl<E, EM, IC, ICB, DI, S, SP, Z> Stage<E, EM, Z> for SyncFromBrokerStage<IC, ICB, DI, S, SP>
where
EM: UsesState<State = S> + EventFirer,
S: UsesInput
+ HasClientPerfMonitor
+ HasExecutions
+ HasCorpus
+ HasRand
+ HasMetadata
+ HasTestcase,
S: State + HasExecutions + HasCorpus + HasRand + HasMetadata + HasTestcase,
SP: ShMemProvider,
E: HasObservers<State = S> + Executor<EM, Z>,
for<'a> E::Observers: Deserialize<'a>,

View File

@ -6,8 +6,6 @@ use core::{fmt::Debug, hash::Hash, marker::PhantomData};
use ahash::RandomState;
use libafl_bolts::{HasLen, Named};
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
corpus::{Corpus, CorpusId, Testcase},
events::EventFirer,
@ -20,9 +18,11 @@ use crate::{
schedulers::{RemovableScheduler, Scheduler},
stages::Stage,
start_timer,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasMaxSize, HasSolutions, UsesState},
state::{HasCorpus, HasExecutions, HasMaxSize, HasSolutions, State, UsesState},
Error, ExecutesInput, ExecutionProcessor, HasFeedback, HasScheduler,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
/// Mutational stage which minimizes corpus entries.
///
@ -30,7 +30,7 @@ use crate::{
pub trait TMinMutationalStage<CS, E, EM, F1, F2, M, OT, Z>:
Stage<E, EM, Z> + FeedbackFactory<F2, CS::State, OT>
where
Self::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize + HasClientPerfMonitor,
Self::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize,
<Self::State as UsesInput>::Input: HasLen + Hash,
CS: Scheduler<State = Self::State> + RemovableScheduler,
E: Executor<EM, Z> + HasObservers<Observers = OT, State = Self::State>,
@ -195,8 +195,7 @@ impl<CS, E, EM, F1, F2, FF, M, OT, Z> Stage<E, EM, Z>
for StdTMinMutationalStage<CS, E, EM, F1, F2, FF, M, OT, Z>
where
CS: Scheduler + RemovableScheduler,
CS::State:
HasCorpus + HasSolutions + HasExecutions + HasMaxSize + HasClientPerfMonitor + HasCorpus,
CS::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize + HasCorpus,
<CS::State as UsesInput>::Input: HasLen + Hash,
E: Executor<EM, Z> + HasObservers<Observers = OT, State = CS::State>,
EM: EventFirer<State = CS::State>,
@ -233,7 +232,6 @@ where
F2: Feedback<Z::State>,
FF: FeedbackFactory<F2, Z::State, OT>,
Z: UsesState,
Z::State: HasClientPerfMonitor,
{
fn create_feedback(&self, ctx: &OT) -> F2 {
self.factory.create_feedback(ctx)
@ -252,7 +250,7 @@ where
<CS::State as UsesInput>::Input: HasLen + Hash,
M: Mutator<CS::Input, CS::State>,
OT: ObserversTuple<CS::State>,
CS::State: HasClientPerfMonitor + HasCorpus + HasSolutions + HasExecutions + HasMaxSize,
CS::State: HasCorpus + HasSolutions + HasExecutions + HasMaxSize,
Z: ExecutionProcessor<OT, State = CS::State>
+ ExecutesInput<E, EM>
+ HasFeedback<Feedback = F1>
@ -332,7 +330,7 @@ impl<M, S> HasObserverName for MapEqualityFeedback<M, S> {
impl<M, S> Feedback<S> for MapEqualityFeedback<M, S>
where
M: MapObserver,
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn is_interesting<EM, OT>(
&mut self,
@ -383,7 +381,7 @@ impl<M, OT, S> FeedbackFactory<MapEqualityFeedback<M, S>, S, OT> for MapEquality
where
M: MapObserver,
OT: ObserversTuple<S>,
S: UsesInput + HasClientPerfMonitor + Debug,
S: State + Debug,
{
fn create_feedback(&self, observers: &OT) -> MapEqualityFeedback<M, S> {
let obs = observers

View File

@ -2,8 +2,6 @@
use core::{fmt::Debug, marker::PhantomData};
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
corpus::{Corpus, CorpusId},
executors::{Executor, HasObservers, ShadowExecutor},
@ -11,9 +9,11 @@ use crate::{
observers::ObserversTuple,
stages::Stage,
start_timer,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, State, UsesState},
state::{HasCorpus, HasExecutions, State, UsesState},
Error,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
/// A stage that runs a tracer executor
#[derive(Clone, Debug)]
@ -34,7 +34,7 @@ impl<E, EM, TE, Z> Stage<E, EM, Z> for TracingStage<EM, TE, Z>
where
E: UsesState<State = TE::State>,
TE: Executor<EM, Z> + HasObservers,
TE::State: HasClientPerfMonitor + HasExecutions + HasCorpus,
TE::State: HasExecutions + HasCorpus,
EM: UsesState<State = TE::State>,
Z: UsesState<State = TE::State>,
{
@ -115,7 +115,7 @@ where
EM: UsesState<State = E::State>,
SOT: ObserversTuple<E::State>,
Z: UsesState<State = E::State>,
E::State: State + HasClientPerfMonitor + HasExecutions + HasCorpus + Debug,
E::State: State + HasExecutions + HasCorpus + Debug,
{
#[inline]
fn perform(
@ -160,7 +160,7 @@ where
impl<E, EM, SOT, Z> ShadowTracingStage<E, EM, SOT, Z>
where
E: Executor<EM, Z> + HasObservers,
E::State: State + HasClientPerfMonitor + HasExecutions + HasCorpus,
E::State: State + HasExecutions + HasCorpus,
EM: UsesState<State = E::State>,
SOT: ObserversTuple<E::State>,
Z: UsesState<State = E::State>,

View File

@ -6,8 +6,6 @@ use core::{marker::PhantomData, time::Duration};
use libafl_bolts::{current_time, impl_serdeany, rands::Rand};
use serde::{Deserialize, Serialize};
#[cfg(feature = "introspection")]
use crate::monitors::PerfFeature;
use crate::{
corpus::{Corpus, CorpusId},
mark_feature_time,
@ -17,9 +15,11 @@ use crate::{
MutationalStage, Stage,
},
start_timer,
state::{HasClientPerfMonitor, HasCorpus, HasMetadata, HasNamedMetadata, HasRand, UsesState},
state::{HasCorpus, HasMetadata, HasNamedMetadata, HasRand, UsesState},
Error, Evaluator,
};
#[cfg(feature = "introspection")]
use crate::{monitors::PerfFeature, state::HasClientPerfMonitor};
#[cfg_attr(
any(not(feature = "serdeany_autoreg"), miri),
@ -161,7 +161,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasNamedMetadata + HasMetadata,
Z::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata,
I: MutatedTransform<Z::Input, Z::State> + Clone,
{
/// Runs this (mutational) stage for the given `testcase`
@ -254,7 +254,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand,
Z::State: HasCorpus + HasRand,
I: MutatedTransform<Z::Input, Z::State> + Clone,
{
type State = Z::State;
@ -266,7 +266,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasNamedMetadata + HasMetadata,
Z::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata,
I: MutatedTransform<Z::Input, Z::State> + Clone,
{
#[inline]
@ -294,7 +294,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasNamedMetadata + HasMetadata,
Z::State: HasCorpus + HasRand + HasNamedMetadata + HasMetadata,
I: MutatedTransform<Z::Input, Z::State> + Clone,
{
/// Creates a new default tuneable mutational stage
@ -462,7 +462,7 @@ where
EM: UsesState<State = Z::State>,
M: Mutator<I, Z::State>,
Z: Evaluator<E, EM>,
Z::State: HasClientPerfMonitor + HasCorpus + HasRand + HasNamedMetadata,
Z::State: HasCorpus + HasRand + HasNamedMetadata,
{
/// Creates a new tranforming mutational stage
#[must_use]

View File

@ -19,6 +19,10 @@ use libafl_bolts::{
};
use serde::{de::DeserializeOwned, Deserialize, Serialize};
#[cfg(feature = "introspection")]
use crate::monitors::ClientPerfMonitor;
#[cfg(feature = "scalability_introspection")]
use crate::monitors::ScalabilityMonitor;
use crate::{
corpus::{Corpus, CorpusId, HasTestcase, Testcase},
events::{Event, EventFirer, LogSeverity},
@ -26,7 +30,6 @@ use crate::{
fuzzer::{Evaluator, ExecuteInputResult},
generators::Generator,
inputs::{Input, UsesInput},
monitors::ClientPerfMonitor,
Error,
};
@ -36,12 +39,15 @@ pub const DEFAULT_MAX_SIZE: usize = 1_048_576;
/// The [`State`] of the fuzzer.
/// Contains all important information about the current run.
/// Will be used to restart the fuzzing process at any time.
pub trait State: UsesInput + Serialize + DeserializeOwned {}
pub trait State:
UsesInput + Serialize + DeserializeOwned + MaybeHasClientPerfMonitor + MaybeHasScalabilityMonitor
{
}
/// Structs which implement this trait are aware of the state. This is used for type enforcement.
pub trait UsesState: UsesInput<Input = <Self::State as UsesInput>::Input> {
/// The state known by this type.
type State: UsesInput;
type State: State;
}
// blanket impl which automatically defines UsesInput for anything that implements UsesState
@ -92,6 +98,7 @@ pub trait HasRand {
fn rand_mut(&mut self) -> &mut Self::Rand;
}
#[cfg(feature = "introspection")]
/// Trait for offering a [`ClientPerfMonitor`]
pub trait HasClientPerfMonitor {
/// [`ClientPerfMonitor`] itself
@ -101,6 +108,43 @@ pub trait HasClientPerfMonitor {
fn introspection_monitor_mut(&mut self) -> &mut ClientPerfMonitor;
}
/// Intermediate trait for `HasClientPerfMonitor`
#[cfg(feature = "introspection")]
pub trait MaybeHasClientPerfMonitor: HasClientPerfMonitor {}
/// Intermediate trait for `HasClientPerfmonitor`
#[cfg(not(feature = "introspection"))]
pub trait MaybeHasClientPerfMonitor {}
#[cfg(not(feature = "introspection"))]
impl<T> MaybeHasClientPerfMonitor for T {}
#[cfg(feature = "introspection")]
impl<T> MaybeHasClientPerfMonitor for T where T: HasClientPerfMonitor {}
/// Intermediate trait for `HasScalabilityMonitor`
#[cfg(feature = "scalability_monitor")]
pub trait MaybeHasScalabilityMonitor: HasScalabilityMonitor {}
/// Intermediate trait for `HasScalabilityMonitor`
#[cfg(not(feature = "scalability_monitor"))]
pub trait MaybeHasScalabilityMonitor {}
#[cfg(not(feature = "scalability_monitor"))]
impl<T> MaybeHasScalabilityMonitor for T {}
#[cfg(feature = "scalability_monitor")]
impl<T> MaybeHasScalabilityMonitor for T where T: HasScalabilityMonitor {}
/// Trait for offering a [`ScalabilityMonitor`]
#[cfg(feature = "scalability_monitor")]
pub trait HasScalabilityMonitor {
/// Ref to [`ScalabilityMonitor`]
fn scalability_monitor(&self) -> &ScalabilityMonitor;
/// Mutable ref to [`ScalabilityMonitor`]
fn scalability_monitor_mut(&mut self) -> &mut ScalabilityMonitor;
}
/// Trait for elements offering metadata
pub trait HasMetadata {
/// A map, storing all metadata
@ -266,6 +310,8 @@ pub struct StdState<I, C, R, SC> {
/// Performance statistics for this fuzzer
#[cfg(feature = "introspection")]
introspection_monitor: ClientPerfMonitor,
#[cfg(feature = "scalability_introspection")]
scalability_monitor: ScalabilityMonitor,
#[cfg(feature = "std")]
/// Remaining initial inputs to load, if any
remaining_initial_files: Option<Vec<PathBuf>>,
@ -844,6 +890,8 @@ where
max_size: DEFAULT_MAX_SIZE,
#[cfg(feature = "introspection")]
introspection_monitor: ClientPerfMonitor::new(),
#[cfg(feature = "scalability_introspection")]
scalability_monitor: ScalabilityMonitor::new(),
#[cfg(feature = "std")]
remaining_initial_files: None,
#[cfg(feature = "std")]
@ -868,14 +916,14 @@ impl<I, C, R, SC> HasClientPerfMonitor for StdState<I, C, R, SC> {
}
}
#[cfg(not(feature = "introspection"))]
impl<I, C, R, SC> HasClientPerfMonitor for StdState<I, C, R, SC> {
fn introspection_monitor(&self) -> &ClientPerfMonitor {
unimplemented!()
#[cfg(feature = "scalability_introspection")]
impl<I, C, R, SC> HasScalabilityMonitor for StdState<I, C, R, SC> {
fn scalability_monitor(&self) -> &ScalabilityMonitor {
&self.scalability_monitor
}
fn introspection_monitor_mut(&mut self) -> &mut ClientPerfMonitor {
unimplemented!()
fn scalability_monitor_mut(&mut self) -> &mut ScalabilityMonitor {
&mut self.scalability_monitor
}
}
@ -950,18 +998,19 @@ impl<I> HasRand for NopState<I> {
}
}
impl<I> State for NopState<I> where I: Input {}
#[cfg(feature = "introspection")]
impl<I> HasClientPerfMonitor for NopState<I> {
fn introspection_monitor(&self) -> &ClientPerfMonitor {
unimplemented!()
unimplemented!();
}
fn introspection_monitor_mut(&mut self) -> &mut ClientPerfMonitor {
unimplemented!()
unimplemented!();
}
}
impl<I> State for NopState<I> where I: Input {}
#[cfg(feature = "python")]
#[allow(missing_docs)]
/// `State` Python bindings

View File

@ -14,7 +14,7 @@ use libafl::{
feedbacks::Feedback,
inputs::{HasTargetBytes, UsesInput},
observers::{Observer, ObserversTuple},
state::{HasClientPerfMonitor, HasMetadata},
state::{HasMetadata, State},
Error,
};
use libafl_bolts::{ownedref::OwnedPtr, Named, SerdeAny};
@ -611,7 +611,7 @@ pub struct AsanErrorsFeedback<S> {
impl<S> Feedback<S> for AsanErrorsFeedback<S>
where
S: UsesInput + Debug + HasClientPerfMonitor,
S: State + Debug,
S::Input: HasTargetBytes,
{
#[allow(clippy::wrong_self_convention)]

View File

@ -8,13 +8,13 @@ use frida_gum::{
#[cfg(windows)]
use libafl::{
executors::inprocess::{HasInProcessHandlers, InProcessHandlers},
state::{HasClientPerfMonitor, HasCorpus, HasSolutions},
state::{HasCorpus, HasSolutions},
};
use libafl::{
executors::{Executor, ExitKind, HasObservers, InProcessExecutor},
inputs::{HasTargetBytes, UsesInput},
inputs::HasTargetBytes,
observers::{ObserversTuple, UsesObservers},
state::{HasExecutions, UsesState},
state::{HasExecutions, State, UsesState},
Error,
};
@ -29,7 +29,7 @@ pub struct FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S::Input: HasTargetBytes,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
'a: 'b,
{
@ -47,7 +47,7 @@ where
impl<'a, 'b, 'c, H, OT, RT, S> Debug for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
S::Input: HasTargetBytes,
OT: ObserversTuple<S> + Debug,
{
@ -65,7 +65,7 @@ impl<'a, 'b, 'c, EM, H, OT, RT, S, Z> Executor<EM, Z>
where
EM: UsesState<State = S>,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,
RT: FridaRuntimeTuple,
@ -118,7 +118,7 @@ impl<'a, 'b, 'c, H, OT, RT, S> UsesObservers for FridaInProcessExecutor<'a, 'b,
where
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
S::Input: HasTargetBytes,
{
type Observers = OT;
@ -128,7 +128,7 @@ impl<'a, 'b, 'c, H, OT, RT, S> UsesState for FridaInProcessExecutor<'a, 'b, 'c,
where
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
S::Input: HasTargetBytes,
{
type State = S;
@ -138,7 +138,7 @@ impl<'a, 'b, 'c, H, OT, RT, S> HasObservers for FridaInProcessExecutor<'a, 'b, '
where
H: FnMut(&S::Input) -> ExitKind,
S::Input: HasTargetBytes,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
{
#[inline]
@ -155,7 +155,7 @@ where
impl<'a, 'b, 'c, H, OT, S, RT> FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,
RT: FridaRuntimeTuple,
@ -231,7 +231,7 @@ impl<'a, 'b, 'c, H, OT, RT, S> HasInProcessHandlers
for FridaInProcessExecutor<'a, 'b, 'c, H, OT, RT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasClientPerfMonitor + HasSolutions + HasCorpus + HasExecutions,
S: State + HasSolutions + HasCorpus + HasExecutions,
S::Input: HasTargetBytes,
OT: ObserversTuple<S>,
RT: FridaRuntimeTuple,

View File

@ -7,9 +7,9 @@ use libafl::{
events::EventFirer,
executors::ExitKind,
feedbacks::{Feedback, MinMapFeedback},
inputs::{BytesInput, Input, UsesInput},
inputs::{BytesInput, Input},
observers::ObserversTuple,
state::{HasClientPerfMonitor, HasMetadata},
state::{HasMetadata, State},
Error,
};
use libafl_bolts::{impl_serdeany, Named};
@ -43,7 +43,7 @@ impl Named for LibfuzzerKeepFeedback {
impl<S> Feedback<S> for LibfuzzerKeepFeedback
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn is_interesting<EM, OT>(
&mut self,
@ -113,7 +113,7 @@ impl LibfuzzerCrashCauseFeedback {
impl<S> Feedback<S> for LibfuzzerCrashCauseFeedback
where
S: UsesInput<Input = BytesInput> + HasClientPerfMonitor,
S: State<Input = BytesInput>,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -23,7 +23,7 @@ use libafl::{
},
stages::StagesTuple,
state::{
HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata, HasSolutions,
HasExecutions, HasLastReportTime, HasMetadata, HasSolutions,
UsesState,
},
Error, Fuzzer,
@ -70,8 +70,7 @@ fn do_fuzz<F, ST, E, S, EM>(
) -> Result<(), Error>
where
F: Fuzzer<E, EM, ST, State = S>,
S: HasClientPerfMonitor
+ HasMetadata
S: HasMetadata
+ HasExecutions
+ UsesInput
+ HasSolutions

View File

@ -8,7 +8,7 @@ use libafl::{
monitors::SimpleMonitor,
stages::StagesTuple,
state::{
HasClientPerfMonitor, HasExecutions, HasLastReportTime, HasMetadata, HasNamedMetadata,
HasExecutions, HasLastReportTime, HasMetadata, HasNamedMetadata,
},
Error, Fuzzer,
};
@ -26,8 +26,7 @@ fn do_report<F, ST, E, S, EM>(
) -> Result<(), Error>
where
F: Fuzzer<E, EM, ST, State = S>,
S: HasClientPerfMonitor
+ HasMetadata
S: HasMetadata
+ HasNamedMetadata
+ HasExecutions
+ UsesInput

View File

@ -8,7 +8,7 @@ use libafl::{
feedbacks::MapNoveltiesMetadata,
inputs::UsesInput,
schedulers::{RemovableScheduler, Scheduler},
state::{HasCorpus, HasMetadata, UsesState},
state::{HasCorpus, HasMetadata, UsesState, State},
Error,
};
@ -21,14 +21,14 @@ pub struct MergeScheduler<S> {
impl<S> UsesState for MergeScheduler<S>
where
S: UsesInput,
S: State,
{
type State = S;
}
impl<S> RemovableScheduler for MergeScheduler<S>
where
S: UsesInput + HasCorpus,
S: State + HasCorpus,
{
fn on_remove(
&mut self,
@ -43,7 +43,7 @@ where
impl<S> Scheduler for MergeScheduler<S>
where
S: UsesInput + HasCorpus,
S: State + HasCorpus,
{
fn on_add(&mut self, state: &mut Self::State, idx: CorpusId) -> Result<(), Error> {
self.all.insert(idx);

View File

@ -2,7 +2,7 @@ use std::{fmt::Debug, marker::PhantomData};
use libafl::{
executors::{Executor, ExitKind, HasObservers},
inputs::{HasTargetBytes, UsesInput},
inputs::HasTargetBytes,
observers::{ObserversTuple, UsesObservers},
state::{HasExecutions, State, UsesState},
Error,
@ -32,7 +32,7 @@ impl<'a, S, OT> Debug for NyxExecutor<'a, S, OT> {
impl<'a, S, OT> UsesState for NyxExecutor<'a, S, OT>
where
S: UsesInput,
S: State,
{
type State = S;
}
@ -40,7 +40,7 @@ where
impl<'a, S, OT> UsesObservers for NyxExecutor<'a, S, OT>
where
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
{
type Observers = OT;
}
@ -48,7 +48,7 @@ where
impl<'a, EM, S, Z, OT> Executor<EM, Z> for NyxExecutor<'a, S, OT>
where
EM: UsesState<State = S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
S::Input: HasTargetBytes,
Z: UsesState<State = S>,
{

View File

@ -20,7 +20,7 @@ use libafl::{
fuzzer::HasObjective,
inputs::UsesInput,
observers::{ObserversTuple, UsesObservers},
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions, State, UsesState},
state::{HasCorpus, HasExecutions, HasSolutions, State, UsesState},
Error,
};
use libafl_bolts::os::unix_signals::{siginfo_t, ucontext_t, Signal};
@ -32,7 +32,7 @@ use crate::{emu::Emulator, helper::QemuHelperTuple, hooks::QemuHooks};
pub struct QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
{
@ -44,7 +44,7 @@ where
impl<'a, H, OT, QT, S> Debug for QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
OT: ObserversTuple<S> + Debug,
QT: QemuHelperTuple<S> + Debug,
{
@ -81,7 +81,7 @@ pub unsafe fn inproc_qemu_crash_handler<E, EM, OF, Z>(
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasExecutions + HasSolutions + HasClientPerfMonitor + HasCorpus,
E::State: HasExecutions + HasSolutions + HasCorpus,
Z: HasObjective<Objective = OF, State = E::State>,
{
let real_crash = if USE_LIBAFL_CRASH_HANDLER {
@ -118,7 +118,7 @@ pub unsafe fn inproc_qemu_timeout_handler<E, EM, OF, Z>(
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasSolutions + HasClientPerfMonitor + HasCorpus + HasExecutions,
E::State: HasSolutions + HasCorpus + HasExecutions,
Z: HasObjective<Objective = OF, State = E::State>,
{
if BREAK_ON_TMOUT {
@ -133,7 +133,7 @@ pub unsafe fn inproc_qemu_timeout_handler<E, EM, OF, Z>(
impl<'a, H, OT, QT, S> QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
{
@ -148,7 +148,7 @@ where
where
EM: EventFirer<State = S> + EventRestarter<State = S>,
OF: Feedback<S>,
S: State + HasExecutions + HasCorpus + HasSolutions + HasClientPerfMonitor,
S: State + HasExecutions + HasCorpus + HasSolutions,
Z: HasObjective<Objective = OF, State = S>,
{
let mut inner = InProcessExecutor::new(harness_fn, observers, fuzzer, state, event_mgr)?;
@ -203,7 +203,7 @@ impl<'a, EM, H, OT, QT, S, Z> Executor<EM, Z> for QemuExecutor<'a, H, OT, QT, S>
where
EM: UsesState<State = S>,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
Z: UsesState<State = S>,
@ -237,7 +237,7 @@ where
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
S: State,
{
type State = S;
}
@ -247,7 +247,7 @@ where
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
S: State,
{
type Observers = OT;
}
@ -255,7 +255,7 @@ where
impl<'a, H, OT, QT, S> HasObservers for QemuExecutor<'a, H, OT, QT, S>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
{
@ -305,7 +305,7 @@ where
impl<'a, H, OT, QT, S, SP> QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
SP: ShMemProvider,
@ -322,7 +322,7 @@ where
where
EM: EventFirer<State = S> + EventRestarter,
OF: Feedback<S>,
S: HasSolutions + HasClientPerfMonitor,
S: HasSolutions,
Z: HasObjective<Objective = OF, State = S>,
{
assert!(!QT::HOOKS_DO_SIDE_EFFECTS, "When using QemuForkExecutor, the hooks must not do any side effect as they will happen in the child process and then discarded");
@ -367,7 +367,7 @@ impl<'a, EM, H, OT, QT, S, Z, SP> Executor<EM, Z> for QemuForkExecutor<'a, H, OT
where
EM: EventManager<InProcessForkExecutor<'a, H, OT, S, SP>, Z, State = S>,
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput + HasClientPerfMonitor + HasMetadata + HasExecutions + HasLastReportTime,
S: State + HasMetadata + HasExecutions + HasLastReportTime,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
SP: ShMemProvider,
@ -403,7 +403,7 @@ where
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type Observers = OT;
@ -415,7 +415,7 @@ where
H: FnMut(&S::Input) -> ExitKind,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -425,7 +425,7 @@ where
impl<'a, H, OT, QT, S, SP> HasObservers for QemuForkExecutor<'a, H, OT, QT, S, SP>
where
H: FnMut(&S::Input) -> ExitKind,
S: UsesInput,
S: State,
OT: ObserversTuple<S>,
QT: QemuHelperTuple<S>,
SP: ShMemProvider,

View File

@ -1,13 +1,15 @@
use alloc::string::{String, ToString};
use core::marker::PhantomData;
#[cfg(feature = "introspection")]
use libafl::state::HasClientPerfMonitor;
use libafl::{
corpus::{Corpus, CorpusId},
executors::{Executor, HasObservers},
inputs::{BytesInput, UsesInput},
observers::ObserversTuple,
stages::{colorization::TaintMetadata, Stage},
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata, UsesState},
state::{HasCorpus, HasExecutions, HasMetadata, UsesState},
Error,
};
use libafl_bolts::tuples::MatchName;
@ -34,11 +36,7 @@ impl<E, EM, TE, Z> Stage<E, EM, Z> for AFLppCmplogTracingStage<EM, TE, Z>
where
E: UsesState<State = TE::State>,
TE: Executor<EM, Z> + HasObservers,
TE::State: HasClientPerfMonitor
+ HasExecutions
+ HasCorpus
+ HasMetadata
+ UsesInput<Input = BytesInput>,
TE::State: HasExecutions + HasCorpus + HasMetadata + UsesInput<Input = BytesInput>,
EM: UsesState<State = TE::State>,
Z: UsesState<State = TE::State>,
{

View File

@ -7,7 +7,7 @@ use libafl::{
feedbacks::Feedback,
inputs::UsesInput,
observers::{Observer, ObserversTuple},
state::HasClientPerfMonitor,
state::State,
Error,
};
use libafl_bolts::Named;
@ -149,7 +149,7 @@ impl Named for OomFeedback {
impl<S> Feedback<S> for OomFeedback
where
S: UsesInput + HasClientPerfMonitor,
S: State,
{
fn is_interesting<EM, OT>(
&mut self,

View File

@ -4,7 +4,7 @@ use libafl::{
events::{EventFirer, EventRestarter},
executors::{inprocess::windows_asan_handler::asan_death_handler, Executor, HasObservers},
feedbacks::Feedback,
state::{HasClientPerfMonitor, HasCorpus, HasExecutions, HasSolutions},
state::{HasCorpus, HasExecutions, HasSolutions},
HasObjective,
};
@ -32,7 +32,7 @@ where
E: Executor<EM, Z> + HasObservers,
EM: EventFirer<State = E::State> + EventRestarter<State = E::State>,
OF: Feedback<E::State>,
E::State: HasSolutions + HasClientPerfMonitor + HasCorpus + HasExecutions,
E::State: HasSolutions + HasCorpus + HasExecutions,
Z: HasObjective<Objective = OF, State = E::State>,
{
__sanitizer_set_death_callback(asan_death_handler::<E, EM, OF, Z>);

View File

@ -3,7 +3,7 @@ use std::time::Duration;
use libafl::{
executors::{Executor, ExitKind, HasObservers},
inputs::{HasTargetBytes, UsesInput},
inputs::HasTargetBytes,
observers::{ObserversTuple, UsesObservers},
state::{HasExecutions, State, UsesState},
Error,
@ -43,7 +43,7 @@ where
impl<'a, EM, S, SP, OT, Z> Executor<EM, Z> for TinyInstExecutor<'a, S, SP, OT>
where
EM: UsesState<State = S>,
S: UsesInput + HasExecutions,
S: State + HasExecutions,
S::Input: HasTargetBytes,
SP: ShMemProvider,
Z: UsesState<State = S>,
@ -310,7 +310,7 @@ where
}
impl<'a, S, SP, OT> UsesState for TinyInstExecutor<'a, S, SP, OT>
where
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type State = S;
@ -318,7 +318,7 @@ where
impl<'a, S, SP, OT> UsesObservers for TinyInstExecutor<'a, S, SP, OT>
where
OT: ObserversTuple<S>,
S: UsesInput,
S: State,
SP: ShMemProvider,
{
type Observers = OT;