Skip to content

Commit

Permalink
rem
Browse files Browse the repository at this point in the history
  • Loading branch information
tokatoka committed Jan 11, 2025
1 parent aa0391e commit 833c4a9
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 220 deletions.
2 changes: 1 addition & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
- `Qemu` cannot be used to initialize `Emulator` directly anymore. Instead, `Qemu` should be initialized through `Emulator` systematically if `Emulator` should be used.
- Related: `EmulatorBuilder` uses a single function to provide a `Qemu` initializer: `EmulatorBuilder::qemu_parameters`. For now, it can be either a `Vec<String>` or a `QemuConfig` instance.
- Related: Qemu's `AsanModule` does not need any special call to `Qemu` init methods anymore. It is now possible to simply initialize `AsanModule` (or `AsanGuestModule`) with a reference to the environment as parameter.

- `CustomBufHandlers` has been deleted. Please use `EventManagerHooksTuple` from now on.
# 0.14.0 -> 0.14.1
- Removed `with_observers` from `Executor` trait.
- `MmapShMemProvider::new_shmem_persistent` has been removed in favour of `MmapShMem::persist`. You probably want to do something like this: `let shmem = MmapShMemProvider::new()?.new_shmem(size)?.persist()?;`
Expand Down
1 change: 0 additions & 1 deletion libafl/src/events/broker_hooks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ where
log::log!((*severity_level).into(), "{message}");
Ok(BrokerEventResult::Handled)
}
Event::CustomBuf { .. } => Ok(BrokerEventResult::Forward),
Event::Stop => Ok(BrokerEventResult::Forward),
//_ => Ok(BrokerEventResult::Forward),
}
Expand Down
26 changes: 4 additions & 22 deletions libafl/src/events/centralized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// 3. The "main evaluator", the evaluator node that will evaluate all the testcases pass by the centralized event manager to see if the testcases are worth propagating
// 4. The "main broker", the gathers the stats from the fuzzer clients and broadcast the newly found testcases from the main evaluator.

use alloc::{boxed::Box, string::String, vec::Vec};
use alloc::{string::String, vec::Vec};
use core::{fmt::Debug, time::Duration};
use std::{marker::PhantomData, process};

Expand All @@ -30,9 +30,9 @@ use crate::events::llmp::COMPRESS_THRESHOLD;
use crate::{
corpus::Corpus,
events::{
AdaptiveSerializer, CustomBufEventResult, Event, EventConfig, EventFirer, EventManager,
EventManagerHooksTuple, EventManagerId, EventProcessor, EventRestarter,
HasCustomBufHandlers, HasEventManagerId, LogSeverity, ProgressReporter,
AdaptiveSerializer, Event, EventConfig, EventFirer, EventManager, EventManagerHooksTuple,
EventManagerId, EventProcessor, EventRestarter, HasEventManagerId, LogSeverity,
ProgressReporter,
},
executors::{Executor, HasObservers},
fuzzer::{EvaluatorObservers, ExecutionProcessor},
Expand Down Expand Up @@ -417,24 +417,6 @@ where
{
}

impl<EM, EMH, S, SP> HasCustomBufHandlers for CentralizedEventManager<EM, EMH, S, SP>
where
EM: HasCustomBufHandlers<State = S>,
EMH: EventManagerHooksTuple<S>,
S: State,
SP: ShMemProvider,
{
/// Adds a custom buffer handler that will run for each incoming `CustomBuf` event.
fn add_custom_buf_handler(
&mut self,
handler: Box<
dyn FnMut(&mut Self::State, &str, &[u8]) -> Result<CustomBufEventResult, Error>,
>,
) {
self.inner.add_custom_buf_handler(handler);
}
}

impl<EM, EMH, S, SP> ProgressReporter for CentralizedEventManager<EM, EMH, S, SP>
where
EM: AdaptiveSerializer + ProgressReporter<State = S> + HasEventManagerId,
Expand Down
33 changes: 3 additions & 30 deletions libafl/src/events/llmp/mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#[cfg(feature = "std")]
use alloc::string::ToString;
use alloc::{boxed::Box, vec::Vec};
use alloc::vec::Vec;
use core::{marker::PhantomData, time::Duration};
#[cfg(feature = "std")]
use std::net::TcpStream;
Expand Down Expand Up @@ -33,9 +33,8 @@ use crate::{
corpus::Corpus,
events::{
llmp::{LLMP_TAG_EVENT_TO_BOTH, _LLMP_TAG_EVENT_TO_BROKER},
AdaptiveSerializer, CustomBufEventResult, CustomBufHandlerFn, Event, EventConfig,
EventFirer, EventManager, EventManagerHooksTuple, EventManagerId, EventProcessor,
EventRestarter, HasCustomBufHandlers, HasEventManagerId, ProgressReporter,
AdaptiveSerializer, Event, EventConfig, EventFirer, EventManager, EventManagerHooksTuple,
EventManagerId, EventProcessor, EventRestarter, HasEventManagerId, ProgressReporter,
},
executors::{Executor, HasObservers},
fuzzer::{Evaluator, EvaluatorObservers, ExecutionProcessor},
Expand Down Expand Up @@ -64,8 +63,6 @@ where
hooks: EMH,
/// The LLMP client for inter process communication
llmp: LlmpClient<SP>,
/// The custom buf handler
custom_buf_handlers: Vec<Box<CustomBufHandlerFn<S>>>,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor,
/// The configuration defines this specific fuzzer.
Expand Down Expand Up @@ -168,7 +165,6 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
should_serialize_cnt: 0,
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}
Expand Down Expand Up @@ -203,7 +199,6 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
should_serialize_cnt: 0,
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}
Expand Down Expand Up @@ -238,7 +233,6 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
should_serialize_cnt: 0,
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}
Expand Down Expand Up @@ -271,7 +265,6 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
should_serialize_cnt: 0,
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}
Expand Down Expand Up @@ -469,13 +462,6 @@ where
}
}
}
Event::CustomBuf { tag, buf } => {
for handler in &mut self.custom_buf_handlers {
if handler(state, &tag, &buf)? == CustomBufEventResult::Handled {
break;
}
}
}
Event::Stop => {
state.request_stop();
}
Expand Down Expand Up @@ -679,19 +665,6 @@ where
{
}

impl<EMH, S, SP> HasCustomBufHandlers for LlmpEventManager<EMH, S, SP>
where
S: State,
SP: ShMemProvider,
{
fn add_custom_buf_handler(
&mut self,
handler: Box<dyn FnMut(&mut S, &str, &[u8]) -> Result<CustomBufEventResult, Error>>,
) {
self.custom_buf_handlers.push(handler);
}
}

impl<EMH, S, SP> ProgressReporter for LlmpEventManager<EMH, S, SP>
where
S: State + HasExecutions + HasMetadata + HasLastReportTime,
Expand Down
21 changes: 1 addition & 20 deletions libafl/src/events/llmp/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! LLMP-backed event manager for scalable multi-processed fuzzing
use alloc::{boxed::Box, vec::Vec};
use core::{marker::PhantomData, time::Duration};

#[cfg(feature = "llmp_compression")]
Expand All @@ -17,7 +16,7 @@ use serde::Deserialize;

use crate::{
corpus::Corpus,
events::{CustomBufEventResult, CustomBufHandlerFn, Event, EventFirer},
events::{Event, EventFirer},
executors::{Executor, HasObservers},
fuzzer::{EvaluatorObservers, ExecutionProcessor},
inputs::{Input, InputConverter, NopInput, NopInputConverter, UsesInput},
Expand Down Expand Up @@ -96,8 +95,6 @@ where
throttle: Option<Duration>,
llmp: LlmpClient<SP>,
last_sent: Duration,
/// The custom buf handler
custom_buf_handlers: Vec<Box<CustomBufHandlerFn<S>>>,
#[cfg(feature = "llmp_compression")]
compressor: GzipCompressor,
converter: Option<IC>,
Expand Down Expand Up @@ -165,7 +162,6 @@ impl LlmpEventConverterBuilder {
converter,
converter_back,
phantom: PhantomData,
custom_buf_handlers: vec![],
})
}

Expand Down Expand Up @@ -195,7 +191,6 @@ impl LlmpEventConverterBuilder {
converter,
converter_back,
phantom: PhantomData,
custom_buf_handlers: vec![],
})
}

Expand Down Expand Up @@ -225,7 +220,6 @@ impl LlmpEventConverterBuilder {
converter,
converter_back,
phantom: PhantomData,
custom_buf_handlers: vec![],
})
}
}
Expand Down Expand Up @@ -324,14 +318,6 @@ where
}
Ok(())
}
Event::CustomBuf { tag, buf } => {
for handler in &mut self.custom_buf_handlers {
if handler(state, &tag, &buf)? == CustomBufEventResult::Handled {
break;
}
}
Ok(())
}
Event::Stop => Ok(()),
_ => Err(Error::unknown(format!(
"Received illegal message that message should not have arrived: {:?}.",
Expand Down Expand Up @@ -449,7 +435,6 @@ where
#[cfg(all(unix, feature = "std", feature = "multi_machine"))]
node_id,
},
Event::CustomBuf { buf, tag } => Event::CustomBuf { buf, tag },
_ => {
return Ok(());
}
Expand Down Expand Up @@ -506,10 +491,6 @@ where
#[cfg(all(unix, feature = "std", feature = "multi_machine"))]
node_id,
},
Event::CustomBuf { buf, tag } => Event::CustomBuf { buf, tag },
_ => {
return Ok(());
}
};
let serialized = postcard::to_allocvec(&converted_event)?;
self.llmp.send_buf(LLMP_TAG_EVENT_TO_BOTH, &serialized)?;
Expand Down
23 changes: 5 additions & 18 deletions libafl/src/events/llmp/restarting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//! When the target crashes, a watch process (the parent) will
//! restart/refork it.
use alloc::{boxed::Box, vec::Vec};
use alloc::vec::Vec;
use core::{
marker::PhantomData,
num::NonZeroUsize,
Expand Down Expand Up @@ -34,10 +34,10 @@ use crate::events::EVENTMGR_SIGHANDLER_STATE;
use crate::{
corpus::Corpus,
events::{
launcher::ClientDescription, AdaptiveSerializer, CustomBufEventResult, Event, EventConfig,
EventFirer, EventManager, EventManagerHooksTuple, EventManagerId, EventProcessor,
EventRestarter, HasCustomBufHandlers, HasEventManagerId, LlmpEventManager,
LlmpShouldSaveState, ProgressReporter, StdLlmpEventHook,
launcher::ClientDescription, AdaptiveSerializer, Event, EventConfig, EventFirer,
EventManager, EventManagerHooksTuple, EventManagerId, EventProcessor, EventRestarter,
HasEventManagerId, LlmpEventManager, LlmpShouldSaveState, ProgressReporter,
StdLlmpEventHook,
},
executors::{Executor, HasObservers},
fuzzer::{Evaluator, EvaluatorObservers, ExecutionProcessor},
Expand Down Expand Up @@ -246,19 +246,6 @@ where
}
}

impl<EMH, S, SP> HasCustomBufHandlers for LlmpRestartingEventManager<EMH, S, SP>
where
S: State,
SP: ShMemProvider,
{
fn add_custom_buf_handler(
&mut self,
handler: Box<dyn FnMut(&mut S, &str, &[u8]) -> Result<CustomBufEventResult, Error>>,
) {
self.llmp_mgr.add_custom_buf_handler(handler);
}
}

/// The llmp connection from the actual fuzzer to the process supervising it
const _ENV_FUZZER_SENDER: &str = "_AFL_ENV_FUZZER_SENDER";
const _ENV_FUZZER_RECEIVER: &str = "_AFL_ENV_FUZZER_RECEIVER";
Expand Down
Loading

0 comments on commit 833c4a9

Please sign in to comment.