Skip to content

Commit

Permalink
No Uses* from fuzzer (AFLplusplus#2761)
Browse files Browse the repository at this point in the history
* go

* fixing stuf

* hello from windows

* more

* lolg

* lolf

* fix

* a

---------

Co-authored-by: Your Name <[email protected]>
  • Loading branch information
tokatoka and Your Name authored Dec 12, 2024
1 parent afc02ee commit cc442f4
Show file tree
Hide file tree
Showing 52 changed files with 495 additions and 595 deletions.
3 changes: 1 addition & 2 deletions fuzzers/baby/baby_fuzzer_custom_executor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ impl<EM, S, Z> Executor<EM, Z> for CustomExecutor<S>
where
EM: UsesState<State = S>,
S: State + HasExecutions,
Z: UsesState<State = S>,
Self::Input: HasTargetBytes,
{
fn run_target(
&mut self,
_fuzzer: &mut Z,
state: &mut Self::State,
state: &mut S,
_mgr: &mut EM,
input: &Self::Input,
) -> Result<ExitKind, libafl::Error> {
Expand Down
5 changes: 2 additions & 3 deletions fuzzers/binary_only/qemu_launcher/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,8 @@ impl<M: Monitor> Instance<'_, M> {
stages: &mut ST,
) -> Result<(), Error>
where
Z: Fuzzer<E, ClientMgr<M>, ST>
+ UsesState<State = ClientState>
+ Evaluator<E, ClientMgr<M>, State = ClientState>,
Z: Fuzzer<E, ClientMgr<M>, ClientState, ST>
+ Evaluator<E, ClientMgr<M>, BytesInput, ClientState>,
E: UsesState<State = ClientState>,
ST: StagesTuple<E, ClientMgr<M>, ClientState, Z>,
{
Expand Down
1 change: 0 additions & 1 deletion fuzzers/forkserver/libafl-fuzz/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ pub enum SupportedExecutors<S, OT, FSV> {
impl<S, OT, FSV, EM, Z> Executor<EM, Z> for SupportedExecutors<S, OT, FSV>
where
S: State,
Z: UsesState<State = S>,
EM: UsesState<State = S>,
FSV: Executor<EM, Z, State = S>,
{
Expand Down
16 changes: 7 additions & 9 deletions fuzzers/forkserver/libafl-fuzz/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use libafl::{
CaptureTimeoutFeedback, ConstFeedback, CrashFeedback, MaxMapFeedback, TimeFeedback,
},
fuzzer::StdFuzzer,
inputs::{BytesInput, NopTargetBytesConverter},
inputs::{BytesInput, NopTargetBytesConverter, UsesInput},
mutators::{havoc_mutations, tokens_mutations, AFLppRedQueen, StdScheduledMutator, Tokens},
observers::{CanTrack, HitcountsMapObserver, StdMapObserver, TimeObserver},
schedulers::{
Expand All @@ -38,7 +38,6 @@ use libafl::{
},
state::{
HasCorpus, HasCurrentTestcase, HasExecutions, HasLastReportTime, HasStartTime, StdState,
UsesState,
},
Error, Fuzzer, HasFeedback, HasMetadata, SerdeAny,
};
Expand Down Expand Up @@ -649,20 +648,19 @@ pub fn fuzzer_target_mode(opt: &Opt) -> Cow<'static, str> {
#[derive(Debug, Serialize, Deserialize, SerdeAny)]
pub struct IsInitialCorpusEntryMetadata {}

pub fn run_fuzzer_with_stages<Z, ST, E, EM>(
pub fn run_fuzzer_with_stages<E, EM, S, ST, Z>(
opt: &Opt,
fuzzer: &mut Z,
stages: &mut ST,
executor: &mut E,
state: &mut <Z as UsesState>::State,
state: &mut S,
mgr: &mut EM,
) -> Result<(), Error>
where
Z: Fuzzer<E, EM, ST>,
E: UsesState<State = Z::State>,
EM: ProgressReporter<State = Z::State>,
ST: StagesTuple<E, EM, Z::State, Z>,
<Z as UsesState>::State: HasLastReportTime + HasExecutions + HasMetadata,
Z: Fuzzer<E, EM, S, ST>,
EM: ProgressReporter<State = S>,
ST: StagesTuple<E, EM, S, Z>,
S: HasLastReportTime + HasExecutions + HasMetadata + UsesInput,
{
if opt.bench_just_one {
fuzzer.fuzz_loop_for(stages, executor, state, mgr, 1)?;
Expand Down
2 changes: 1 addition & 1 deletion libafl/src/corpus/minimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ where
E::Observers: ObserversTuple<E::Input, E::State>,
CS: Scheduler<E::Input, E::State> + RemovableScheduler<E::Input, E::State>,
EM: EventFirer<State = E::State>,
Z: HasScheduler<Scheduler = CS, State = E::State>,
Z: HasScheduler<E::Input, E::State, Scheduler = CS>,
{
// don't delete this else it won't work after restart
let current = *state.corpus().current();
Expand Down
110 changes: 57 additions & 53 deletions libafl/src/events/centralized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::events::llmp::COMPRESS_THRESHOLD;
#[cfg(feature = "scalability_introspection")]
use crate::state::HasScalabilityMonitor;
use crate::{
corpus::Corpus,
events::{
AdaptiveSerializer, CustomBufEventResult, Event, EventConfig, EventFirer, EventManager,
EventManagerHooksTuple, EventManagerId, EventProcessor, EventRestarter,
Expand All @@ -39,7 +40,7 @@ use crate::{
fuzzer::{EvaluatorObservers, ExecutionProcessor},
inputs::{Input, NopInput, UsesInput},
observers::{ObserversTuple, TimeObserver},
state::{HasExecutions, HasLastReportTime, NopState, State, Stoppable, UsesState},
state::{HasCorpus, HasExecutions, HasLastReportTime, NopState, State, Stoppable, UsesState},
Error, HasMetadata,
};

Expand All @@ -49,8 +50,8 @@ pub(crate) const _LLMP_TAG_TO_MAIN: Tag = Tag(0x3453453);
#[derive(Debug)]
pub struct CentralizedEventManager<EM, EMH, S, SP>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand Down Expand Up @@ -114,8 +115,8 @@ impl CentralizedEventManagerBuilder {
time_obs: Option<Handle<TimeObserver>>,
) -> Result<CentralizedEventManager<EM, EMH, S, SP>, Error>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -135,7 +136,6 @@ impl CentralizedEventManagerBuilder {
///
/// If the port is not yet bound, it will act as a broker; otherwise, it
/// will act as a client.
#[cfg(feature = "std")]
pub fn build_on_port<EM, EMH, S, SP>(
self,
inner: EM,
Expand All @@ -145,8 +145,8 @@ impl CentralizedEventManagerBuilder {
time_obs: Option<Handle<TimeObserver>>,
) -> Result<CentralizedEventManager<EM, EMH, S, SP>, Error>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -165,7 +165,6 @@ impl CentralizedEventManagerBuilder {

/// If a client respawns, it may reuse the existing connection, previously
/// stored by [`LlmpClient::to_env()`].
#[cfg(feature = "std")]
pub fn build_existing_client_from_env<EM, EMH, S, SP>(
self,
inner: EM,
Expand All @@ -175,8 +174,8 @@ impl CentralizedEventManagerBuilder {
time_obs: Option<Handle<TimeObserver>>,
) -> Result<CentralizedEventManager<EM, EMH, S, SP>, Error>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -193,7 +192,6 @@ impl CentralizedEventManagerBuilder {
}

/// Create an existing client from description
#[cfg(feature = "std")]
pub fn existing_client_from_description<EM, EMH, S, SP>(
self,
inner: EM,
Expand All @@ -203,8 +201,8 @@ impl CentralizedEventManagerBuilder {
time_obs: Option<Handle<TimeObserver>>,
) -> Result<CentralizedEventManager<EM, EMH, S, SP>, Error>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -222,8 +220,8 @@ impl CentralizedEventManagerBuilder {
}
impl<EM, EMH, S, SP> UsesState for CentralizedEventManager<EM, EMH, S, SP>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -232,8 +230,8 @@ where

impl<EM, EMH, S, SP> AdaptiveSerializer for CentralizedEventManager<EM, EMH, S, SP>
where
EM: AdaptiveSerializer + UsesState,
EMH: EventManagerHooksTuple<EM::State>,
EM: AdaptiveSerializer + UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand Down Expand Up @@ -270,9 +268,10 @@ where

impl<EM, EMH, S, SP> EventFirer for CentralizedEventManager<EM, EMH, S, SP>
where
EM: AdaptiveSerializer + EventFirer + HasEventManagerId,
EMH: EventManagerHooksTuple<EM::State>,
S: State,
EM: AdaptiveSerializer + EventFirer<State = S> + HasEventManagerId,
EMH: EventManagerHooksTuple<S>,
S: State + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
SP: ShMemProvider,
{
fn should_send(&self) -> bool {
Expand Down Expand Up @@ -342,8 +341,8 @@ where

impl<EM, EMH, S, SP> EventRestarter for CentralizedEventManager<EM, EMH, S, SP>
where
EM: EventRestarter,
EMH: EventManagerHooksTuple<EM::State>,
EM: EventRestarter<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -368,17 +367,18 @@ where

impl<E, EM, EMH, S, SP, Z> EventProcessor<E, Z> for CentralizedEventManager<EM, EMH, S, SP>
where
EM: AdaptiveSerializer + EventProcessor<E, Z> + EventFirer + HasEventManagerId,
EMH: EventManagerHooksTuple<EM::State>,
EM: AdaptiveSerializer + EventProcessor<E, Z> + EventFirer<State = S> + HasEventManagerId,
EMH: EventManagerHooksTuple<S>,
E: HasObservers + Executor<Self, Z, State = Self::State>,
E::Observers:
ObserversTuple<<Self as UsesInput>::Input, <Self as UsesState>::State> + Serialize,
for<'a> E::Observers: Deserialize<'a>,
S: State,
S: State + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
Self::State: HasExecutions + HasMetadata,
SP: ShMemProvider,
Z: EvaluatorObservers<Self, E::Observers, State = Self::State>
+ ExecutionProcessor<Self, E::Observers, State = Self::State>,
Z: EvaluatorObservers<E, Self, <S::Corpus as Corpus>::Input, S>
+ ExecutionProcessor<Self, <S::Corpus as Corpus>::Input, E::Observers, S>,
{
fn process(
&mut self,
Expand Down Expand Up @@ -408,20 +408,21 @@ where
E::Observers:
ObserversTuple<<Self as UsesInput>::Input, <Self as UsesState>::State> + Serialize,
for<'a> E::Observers: Deserialize<'a>,
EM: AdaptiveSerializer + EventManager<E, Z>,
EM: AdaptiveSerializer + EventManager<E, Z, State = S>,
EM::State: HasExecutions + HasMetadata + HasLastReportTime,
EMH: EventManagerHooksTuple<EM::State>,
S: State,
EMH: EventManagerHooksTuple<S>,
S: State + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
SP: ShMemProvider,
Z: EvaluatorObservers<Self, E::Observers, State = Self::State>
+ ExecutionProcessor<Self, E::Observers, State = Self::State>,
Z: EvaluatorObservers<E, Self, <S::Corpus as Corpus>::Input, S>
+ ExecutionProcessor<Self, <S::Corpus as Corpus>::Input, E::Observers, S>,
{
}

impl<EM, EMH, S, SP> HasCustomBufHandlers for CentralizedEventManager<EM, EMH, S, SP>
where
EM: HasCustomBufHandlers,
EMH: EventManagerHooksTuple<EM::State>,
EM: HasCustomBufHandlers<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
Expand All @@ -438,19 +439,21 @@ where

impl<EM, EMH, S, SP> ProgressReporter for CentralizedEventManager<EM, EMH, S, SP>
where
EM: AdaptiveSerializer + ProgressReporter + HasEventManagerId,
EM: AdaptiveSerializer + ProgressReporter<State = S> + HasEventManagerId,
EM::State: HasMetadata + HasExecutions + HasLastReportTime,
EMH: EventManagerHooksTuple<EM::State>,
S: State,
EMH: EventManagerHooksTuple<S>,
S: State + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
SP: ShMemProvider,
{
}

impl<EM, EMH, S, SP> HasEventManagerId for CentralizedEventManager<EM, EMH, S, SP>
where
EM: HasEventManagerId + UsesState,
EMH: EventManagerHooksTuple<EM::State>,
S: State,
EM: HasEventManagerId + UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
SP: ShMemProvider,
{
fn mgr_id(&self) -> EventManagerId {
Expand All @@ -460,9 +463,10 @@ where

impl<EM, EMH, S, SP> CentralizedEventManager<EM, EMH, S, SP>
where
EM: UsesState,
EMH: EventManagerHooksTuple<EM::State>,
S: State,
EM: UsesState<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
SP: ShMemProvider,
{
/// Describe the client event manager's LLMP parts in a restorable fashion
Expand All @@ -472,7 +476,6 @@ where

/// Write the config for a client [`EventManager`] to env vars, a new
/// client can reattach using [`CentralizedEventManagerBuilder::build_existing_client_from_env()`].
#[cfg(feature = "std")]
pub fn to_env(&self, env_name: &str) {
self.client.to_env(env_name).unwrap();
}
Expand All @@ -485,9 +488,10 @@ where

impl<EM, EMH, S, SP> CentralizedEventManager<EM, EMH, S, SP>
where
EM: UsesState + EventFirer + AdaptiveSerializer + HasEventManagerId,
EMH: EventManagerHooksTuple<EM::State>,
S: State + Stoppable,
EM: UsesState<State = S> + EventFirer + AdaptiveSerializer + HasEventManagerId,
EMH: EventManagerHooksTuple<S>,
S: State + Stoppable + HasCorpus,
S::Corpus: Corpus<Input = S::Input>,
SP: ShMemProvider,
{
#[cfg(feature = "llmp_compression")]
Expand Down Expand Up @@ -535,8 +539,8 @@ where
ObserversTuple<<Self as UsesInput>::Input, <Self as UsesState>::State> + Serialize,
<Self as UsesState>::State: UsesInput + HasExecutions + HasMetadata,
for<'a> E::Observers: Deserialize<'a>,
Z: ExecutionProcessor<Self, E::Observers, State = <Self as UsesState>::State>
+ EvaluatorObservers<Self, E::Observers>,
Z: EvaluatorObservers<E, Self, <S::Corpus as Corpus>::Input, S>
+ ExecutionProcessor<Self, <S::Corpus as Corpus>::Input, E::Observers, S>,
{
// TODO: Get around local event copy by moving handle_in_client
let self_id = self.client.sender().id();
Expand Down Expand Up @@ -585,8 +589,8 @@ where
ObserversTuple<<Self as UsesInput>::Input, <Self as UsesState>::State> + Serialize,
<Self as UsesState>::State: UsesInput + HasExecutions + HasMetadata,
for<'a> E::Observers: Deserialize<'a> + Serialize,
Z: ExecutionProcessor<Self, E::Observers, State = <Self as UsesState>::State>
+ EvaluatorObservers<Self, E::Observers>,
Z: EvaluatorObservers<E, Self, <S::Corpus as Corpus>::Input, S>
+ ExecutionProcessor<Self, <S::Corpus as Corpus>::Input, E::Observers, S>,
{
log::debug!("handle_in_main!");

Expand Down Expand Up @@ -640,7 +644,7 @@ where
process::id(),
event_name
);
fuzzer.evaluate_input_with_observers::<E>(
fuzzer.evaluate_input_with_observers(
state,
executor,
self,
Expand Down
Loading

0 comments on commit cc442f4

Please sign in to comment.