WIP: type fixing

This commit is contained in:
Alwin Berger 2024-12-04 15:04:38 +01:00
parent 1430532b38
commit b12811e1ef
13 changed files with 119 additions and 97 deletions

View File

@ -60,9 +60,9 @@ codegen-units = 1
debug = true
[dependencies]
libafl = { path = "../../libafl/", features = ["multipart_inputs"] }
libafl = { path = "../../libafl/", features = ["multipart_inputs", "prelude"] }
libafl_bolts = { path = "../../libafl_bolts/" }
libafl_qemu = { path = "../../libafl_qemu/", features = ["arm", "systemmode"] }
libafl_qemu = { path = "../../libafl_qemu/", features = ["arm", "systemmode"], default-features = false }
serde = { version = "1.0", default-features = false, features = ["alloc"] } # serialization lib
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }
hashbrown = { version = "0.14.0", features = ["serde"] } # A faster hashmap, nostd compatible

View File

@ -28,17 +28,17 @@ pub enum DebugFeedback {
static mut counter : usize = 10;
impl<S> Feedback<S> for DebugFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for DebugFeedback
where
S: State,
{
#[inline]
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
_observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -60,7 +60,7 @@ where
Ok((*self).into())
}
fn append_metadata<EM, OT>(
fn append_metadata(
&mut self,
state: &mut S,
_manager: &mut EM,

View File

@ -57,16 +57,16 @@ pub struct NovelSystemStateFeedback
// known_traces: HashMap<u64,(u64,usize)>,
}
impl<S> Feedback<S> for NovelSystemStateFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for NovelSystemStateFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor + HasNamedMetadata,
S::Input: Default,
{
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -126,7 +126,7 @@ where
/// Append to the testcase the generated metadata in case of a new corpus item
#[inline]
fn append_metadata<EM, OT>(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, testcase: &mut Testcase<S::Input>) -> Result<(), Error> {
fn append_metadata(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, testcase: &mut Testcase<<S as UsesInput>::Input>) -> Result<(), Error> {
let a = self.last_trace.take();
match a {
Some(s) => testcase.metadata_map_mut().insert(FreeRTOSSystemStateMetadata::new(s)),
@ -137,7 +137,7 @@ where
/// Discard the stored metadata in case that the testcase is not added to the corpus
#[inline]
fn discard_metadata(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn discard_metadata(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
self.last_trace = None;
Ok(())
}
@ -170,15 +170,15 @@ pub struct DumpSystraceFeedback
last_trace: Option<Vec<ExecInterval>>,
}
impl<S> Feedback<S> for DumpSystraceFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for DumpSystraceFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
{
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -225,7 +225,7 @@ where
}
/// Append to the testcase the generated metadata in case of a new corpus item
#[inline]
fn append_metadata<EM, OT>(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, _testcase: &mut Testcase<S::Input>) -> Result<(), Error> {
fn append_metadata(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, _testcase: &mut Testcase<<S as UsesInput>::Input>) -> Result<(), Error> {
if !self.dump_metadata {return Ok(());}
// let a = self.last_trace.take();
// match a {
@ -237,7 +237,7 @@ where
/// Discard the stored metadata in case that the testcase is not added to the corpus
#[inline]
fn discard_metadata(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn discard_metadata(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
self.last_trace = None;
Ok(())
}
@ -277,20 +277,20 @@ pub struct SystraceErrorFeedback
max_reports: Option<usize>,
}
impl<S> Feedback<S> for SystraceErrorFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for SystraceErrorFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
EM: EventFirer<State = S>,
{
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
where
EM: EventFirer<State = S>,
OT: ObserversTuple<S>
{
#[cfg(feature = "trace_stg")]
@ -313,13 +313,13 @@ where
}
/// Append to the testcase the generated metadata in case of a new corpus item
#[inline]
fn append_metadata<EM, OT>(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, _testcase: &mut Testcase<S::Input>) -> Result<(), Error> {
fn append_metadata(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, _testcase: &mut I) -> Result<(), Error> {
Ok(())
}
/// Discard the stored metadata in case that the testcase is not added to the corpus
#[inline]
fn discard_metadata(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn discard_metadata(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
Ok(())
}
}

View File

@ -160,7 +160,7 @@ impl<S> QemuHelper<S> for QemuSystemStateHelper
where
S: UsesInput,
{
fn first_exec<QT>(&self, _hooks: &QemuHooks<QT, S>)
fn first_exec<QT>(&self, _hooks: &QemuHooks)
where
QT: QemuHelperTuple<S>,
{
@ -179,14 +179,14 @@ where
}
// TODO: refactor duplicate code
fn pre_exec(&mut self, _emulator: libafl_qemu::Qemu, _input: &S::Input) {
fn pre_exec(&mut self, _emulator: libafl_qemu::Qemu, _input: &I) {
unsafe {
CURRENT_SYSTEMSTATE_VEC.clear();
JOBS_DONE.clear();
}
}
fn post_exec<OT>(&mut self, emulator: libafl_qemu::Qemu, _input: &S::Input, _observers: &mut OT, _exit_kind: &mut ExitKind) {
fn post_exec<OT>(&mut self, emulator: libafl_qemu::Qemu, _input: &I, _observers: &mut OT, _exit_kind: &mut ExitKind) {
trigger_collection(&emulator,(0, 0), CaptureEvent::End, self);
unsafe {
let c = emulator.cpu_from_index(0);
@ -341,7 +341,7 @@ fn trigger_collection(emulator: &libafl_qemu::Qemu, edge: (GuestAddr, GuestAddr)
pub static mut JOBS_DONE : Vec<(u64, String)> = vec![];
pub fn job_done_hook<QT, S>(
hooks: &mut QemuHooks<QT, S>,
hooks: &mut QemuHooks,
_state: Option<&mut S>,
_pc: GuestAddr,
)
@ -364,7 +364,7 @@ where
//============================= Trace interrupt service routines
pub fn exec_isr_hook<QT, S>(
hooks: &mut QemuHooks<QT, S>,
hooks: &mut QemuHooks,
_state: Option<&mut S>,
pc: GuestAddr,
)
@ -382,7 +382,7 @@ where
//============================= Trace syscalls and returns
pub fn gen_jmp_is_syscall<QT, S>(
hooks: &mut QemuHooks<QT, S>,
hooks: &mut QemuHooks,
_state: Option<&mut S>,
src: GuestAddr,
dest: GuestAddr,
@ -415,7 +415,7 @@ where
}
pub fn trace_jmp<QT, S>(
hooks: &mut QemuHooks<QT, S>,
hooks: &mut QemuHooks,
_state: Option<&mut S>,
src: GuestAddr, mut dest: GuestAddr, id: u64
)
@ -454,7 +454,7 @@ where
//============================= Read Hooks
#[allow(unused)]
pub fn gen_read_is_input<QT, S>(
hooks: &mut QemuHooks<QT, S>,
hooks: &mut QemuHooks,
_state: Option<&mut S>,
pc: GuestAddr,
_addr: *mut TCGTemp,
@ -478,7 +478,7 @@ static mut MEM_READ : Option<Vec<(GuestAddr, u8)>> = None;
#[allow(unused)]
pub fn trace_reads<QT, S>(
hooks: &mut QemuHooks<QT, S>,
hooks: &mut QemuHooks,
_state: Option<&mut S>,
_id: u64,
addr: GuestAddr,

View File

@ -9,7 +9,7 @@ use libafl_bolts::{rands::{
random_seed, Rand, StdRand
}, Named};
use libafl::{
common::{HasMetadata, HasNamedMetadata}, corpus::{self, Corpus}, events::{Event, EventFirer, EventProcessor, LogSeverity}, fuzzer::Evaluator, inputs::{HasMutatorBytes, HasTargetBytes, Input, MultipartInput}, mark_feature_time, prelude::{new_hash_feedback, AggregatorOps, CorpusId, MutationResult, Mutator, UserStats, UserStatsValue, UsesInput}, stages::Stage, start_timer, state::{HasCorpus, HasRand, MaybeHasClientPerfMonitor, UsesState}, Error
common::{HasMetadata, HasNamedMetadata}, corpus::{self, Corpus}, events::{Event, EventFirer, EventProcessor, LogSeverity}, fuzzer::Evaluator, inputs::{HasMutatorBytes, HasTargetBytes, Input, MultipartInput}, mark_feature_time, {new_hash_feedback, AggregatorOps, CorpusId, MutationResult, Mutator, UserStats, UserStatsValue, UsesInput}, stages::Stage, start_timer, state::{HasCorpus, HasRand, MaybeHasClientPerfMonitor, UsesState}, Error
};
use libafl::prelude::State;
use petgraph::{graph::NodeIndex, graph::{self, DiGraph}};
@ -430,11 +430,11 @@ where
Ok(())
}
fn restart_progress_should_run(&mut self, state: &mut Self::State) -> Result<bool, Error> {
fn should_restart(&mut self, state: &mut Self::State) -> Result<bool, Error> {
Ok(true)
}
fn clear_restart_progress(&mut self, state: &mut Self::State) -> Result<(), Error> {
fn clear_progress(&mut self, state: &mut Self::State) -> Result<(), Error> {
Ok(())
}
}
@ -579,11 +579,11 @@ where
Ok(())
}
fn restart_progress_should_run(&mut self, state: &mut Self::State) -> Result<bool, Error> {
fn should_restart(&mut self, state: &mut Self::State) -> Result<bool, Error> {
Ok(true)
}
fn clear_restart_progress(&mut self, state: &mut Self::State) -> Result<(), Error> {
fn clear_progress(&mut self, state: &mut Self::State) -> Result<(), Error> {
Ok(())
}
}

View File

@ -49,19 +49,19 @@ pub struct QemuSystemStateObserver<I>
name: Cow<'static, str>,
}
impl<S> Observer<S> for QemuSystemStateObserver<S::Input>
impl<I, S> Observer<<S as UsesInput>::Input, S> for QemuSystemStateObserver<<S as UsesInput>::Input>
where
S: UsesInput + HasMetadata,
S::Input: Default
{
#[inline]
fn pre_exec(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn pre_exec(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
unsafe {CURRENT_SYSTEMSTATE_VEC.clear(); }
Ok(())
}
#[inline]
fn post_exec(&mut self, _state: &mut S, _input: &S::Input, _exit_kind: &ExitKind) -> Result<(), Error> {
fn post_exec(&mut self, _state: &mut S, _input: &I, _exit_kind: &ExitKind) -> Result<(), Error> {
// unsafe {self.last_run = invalidate_ineffective_isr(refine_system_states(&mut CURRENT_SYSTEMSTATE_VEC));}
unsafe {
let temp = refine_system_states(CURRENT_SYSTEMSTATE_VEC.split_off(0));

View File

@ -7,7 +7,7 @@ use libafl_bolts::current_time;
use itertools::Itertools;
use libafl::{
corpus::{Corpus, HasCurrentCorpusId}, events::EventFirer, prelude::{minimizer::TopRatedsMetadata, RemovableScheduler}, schedulers::minimizer::IsFavoredMetadata, stages::Stage, state::{HasCorpus, HasImported, UsesState}, Error, HasMetadata, HasScheduler
corpus::{Corpus, HasCurrentCorpusId}, events::EventFirer, schedulers::minimizer::TopRatedsMetadata, RemovableScheduler, schedulers::minimizer::IsFavoredMetadata, stages::Stage, state::{HasCorpus, HasImported, UsesState}, Error, HasMetadata, HasScheduler
};
use libafl::{
events::Event,
@ -149,13 +149,13 @@ where
}
#[inline]
fn restart_progress_should_run(&mut self, _state: &mut <Self as UsesState>::State) -> Result<bool, Error> {
fn should_restart(&mut self, _state: &mut <Self as UsesState>::State) -> Result<bool, Error> {
// Not running the target so we wont't crash/timeout and, hence, don't need to restore anything
Ok(true)
}
#[inline]
fn clear_restart_progress(&mut self, _state: &mut <Self as UsesState>::State) -> Result<(), Error> {
fn clear_progress(&mut self, _state: &mut <Self as UsesState>::State) -> Result<(), Error> {
// Not running the target so we wont't crash/timeout and, hence, don't need to restore anything
Ok(())
}

View File

@ -45,9 +45,9 @@ where
type State = CS::State;
}
impl<CS> Scheduler for LongestTraceScheduler<CS>
impl<CS> Scheduler<CS::State, CS::Input> for LongestTraceScheduler<CS>
where
CS: Scheduler,
CS: UsesState + Scheduler<CS::State, CS::Input>,
CS::State: HasCorpus + HasMetadata + HasRand,
{
/// Add an entry to the corpus and return its index
@ -105,11 +105,19 @@ where
}
Ok(idx)
}
fn set_current_scheduled(
&mut self,
state: &mut <<CS as UsesState>::State as UsesInput>::Input,
next_id: Option<libafl::corpus::CorpusId>,
) -> Result<(), Error> {
self.base.set_current_scheduled(state, next_id)
}
}
impl<CS> LongestTraceScheduler<CS>
where
CS: Scheduler,
CS: UsesState + Scheduler<CS::State, CS::Input>,
CS::State: HasCorpus + HasMetadata + HasRand,
{
pub fn get_update_trace_length(&self, state: &mut CS::State, par: usize) -> u64 {
@ -162,13 +170,13 @@ where
type State = S;
}
impl<S> Scheduler for GenerationScheduler<S>
impl<I, S> Scheduler<I, S> for GenerationScheduler<S>
where
S: State + HasCorpus + HasMetadata,
{
/// get first element in current gen,
/// if current_gen is empty, swap lists, sort by FavFactor, take top k and return first
fn next(&mut self, state: &mut Self::State) -> Result<CorpusId, Error> {
fn next(&mut self, state: &mut S) -> Result<CorpusId, Error> {
let mut to_remove : Vec<(usize, f64)> = vec![];
let mut _to_return : usize = 0;
let corpus_len = state.corpus().count();
@ -220,7 +228,7 @@ where
/// Add the new input to the next generation
fn on_add(
&mut self,
state: &mut Self::State,
state: &mut S,
idx: CorpusId
) -> Result<(), Error> {
// println!("On Add {idx}");
@ -233,6 +241,14 @@ where
}
Ok(())
}
fn set_current_scheduled(
&mut self,
state: &mut S,
next_id: Option<libafl::corpus::CorpusId>,
) -> Result<(), Error> {
self.base.set_current_scheduled(state, next_id)
}
// fn on_replace(
// &self,
// _state: &mut Self::State,

View File

@ -48,6 +48,8 @@ use std::ops::DerefMut;
use std::rc::Rc;
use petgraph::visit::EdgeRef;
use libafl::prelude::StateInitializer;
//============================= Data Structures
#[derive(Serialize, Deserialize, Clone, Debug, Default, Hash)]
pub struct STGNode
@ -522,26 +524,28 @@ impl StgFeedback {
}
}
impl<S> Feedback<S> for StgFeedback
impl<S> StateInitializer<S> for StgFeedback {}
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for StgFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor + HasNamedMetadata,
S::Input: Default,
EM: EventFirer<State = S>,
OT: ObserversTuple<S>,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
where
EM: EventFirer<State = S>,
OT: ObserversTuple<S>,
S::Input: Default,
<S as UsesInput>::Input: Default,
{
let observer = observers.match_name::<QemuSystemStateObserver<S::Input>>("systemstate")
let observer = observers.match_name::<QemuSystemStateObserver<<S as UsesInput>::Input>>("systemstate")
.expect("QemuSystemStateObserver not found");
let clock_observer = observers.match_name::<QemuClockObserver>("clocktime")
.expect("QemuClockObserver not found");
@ -700,7 +704,7 @@ where
/// Append to the testcase the generated metadata in case of a new corpus item
#[inline]
fn append_metadata<EM, OT>(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, testcase: &mut Testcase<S::Input>) -> Result<(), Error> {
fn append_metadata(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, testcase: &mut Testcase<I>) -> Result<(), Error> {
let meta = STGNodeMetadata::new(self.last_node_trace.take().unwrap_or_default(), self.last_edge_trace.take().unwrap_or_default(), self.last_abb_trace.take().unwrap_or_default(), self.last_abbs_hash.take().unwrap_or_default(), self.last_aggregate_hash.take().unwrap_or_default(), self.last_top_abb_hashes.take().unwrap_or_default(), self.last_intervals.take().unwrap_or_default(), self.last_job_trace.take().unwrap_or_default());
testcase.metadata_map_mut().insert(meta);
Ok(())
@ -708,7 +712,7 @@ where
/// Discard the stored metadata in case that the testcase is not added to the corpus
#[inline]
fn discard_metadata(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn discard_metadata(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
Ok(())
}
}

View File

@ -125,11 +125,11 @@ impl QemuClockObserver {
}
}
impl<S> Observer<S> for QemuClockObserver
impl<I, S> Observer<I, S> for QemuClockObserver
where
S: UsesInput + HasMetadata,
{
fn pre_exec(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn pre_exec(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
// Only remember the pre-run ticks if presistent mode ist used
#[cfg(not(feature = "snapshot_restore"))]
unsafe {
@ -142,7 +142,7 @@ where
Ok(())
}
fn post_exec(&mut self, _state: &mut S, _input: &S::Input, _exit_kind: &ExitKind) -> Result<(), Error> {
fn post_exec(&mut self, _state: &mut S, _input: &I, _exit_kind: &ExitKind) -> Result<(), Error> {
unsafe { self.end_tick = libafl_qemu::sys::icount_get_raw() };
if let Some(td) = &self.dump_path {
// println!("clock post {}", self.end_tick);
@ -216,17 +216,17 @@ pub struct ClockTimeFeedback {
name: Cow<'static, str>,
}
impl<S> Feedback<S> for ClockTimeFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for ClockTimeFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor + HasMetadata,
<S as UsesInput>::Input: Default
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -250,12 +250,12 @@ where
/// Append to the testcase the generated metadata in case of a new corpus item
#[inline]
fn append_metadata<EM, OT>(
fn append_metadata(
&mut self,
_state: &mut S,
_manager: &mut EM,
_observers: &OT,
testcase: &mut Testcase<S::Input>,
testcase: &mut Testcase<<S as UsesInput>::Input>,
) -> Result<(), Error> {
*testcase.exec_time_mut() = self.exec_time;
self.exec_time = None;
@ -264,7 +264,7 @@ where
/// Discard the stored metadata in case that the testcase is not added to the corpus
#[inline]
fn discard_metadata(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn discard_metadata(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
self.exec_time = None;
Ok(())
}
@ -305,15 +305,15 @@ pub struct QemuClockIncreaseFeedback {
name: Cow<'static, str>,
}
impl<S> Feedback<S> for QemuClockIncreaseFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for QemuClockIncreaseFeedback
where
S: State + UsesInput + HasNamedMetadata + MaybeHasClientPerfMonitor + Debug,
{
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
_observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -337,14 +337,14 @@ where
/// Append to the testcase the generated metadata in case of a new corpus item
#[inline]
fn append_metadata<EM, OT>(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, _testcase: &mut Testcase<S::Input>) -> Result<(), Error> {
fn append_metadata(&mut self, _state: &mut S, _manager: &mut EM, _observers: &OT, _testcase: &mut Testcase<<S as UsesInput>::Input>) -> Result<(), Error> {
// testcase.metadata_mut().insert(QemuIcountMetadata{runtime: self.last_runtime});
Ok(())
}
/// Discard the stored metadata in case that the testcase is not added to the corpus
#[inline]
fn discard_metadata(&mut self, _state: &mut S, _input: &S::Input) -> Result<(), Error> {
fn discard_metadata(&mut self, _state: &mut S, _input: &I) -> Result<(), Error> {
Ok(())
}

View File

@ -45,23 +45,23 @@ where
{
const HOOKS_DO_SIDE_EFFECTS: bool = true;
fn init_hooks<QT>(&self, _hooks: &QemuHooks<QT, S>)
fn init_hooks<QT>(&self, _hooks: &QemuHooks)
where
QT: QemuHelperTuple<S>,
{
}
fn first_exec<QT>(&self, _hooks: &QemuHooks<QT, S>)
fn first_exec<QT>(&self, _hooks: &QemuHooks)
where
QT: QemuHelperTuple<S>,
{
}
fn post_exec<OT>(&mut self, _emulator: libafl_qemu::Qemu, _input: &S::Input, _observers: &mut OT, _exit_kind: &mut ExitKind) {
fn post_exec<OT>(&mut self, _emulator: libafl_qemu::Qemu, _input: &I, _observers: &mut OT, _exit_kind: &mut ExitKind) {
// unsafe { println!("snapshot post {}",emu::icount_get_raw()) };
}
fn pre_exec(&mut self, emulator: libafl_qemu::Qemu, _input: &S::Input) {
fn pre_exec(&mut self, emulator: libafl_qemu::Qemu, _input: &I) {
// only restore in pre-exec, to preserve the post-execution state for inspection
#[cfg(feature = "snapshot_restore")]
{

View File

@ -26,6 +26,8 @@ use std::time::Duration;
use std::time::Instant;
use std::ops::Sub;
use libafl::corpus::Corpus;
use libafl_bolts::{
AsSlice, ClientId, HasLen, Named
};
@ -77,7 +79,7 @@ pub type TimeStateMaximizerCorpusScheduler<CS, O> =
pub struct MaxExecsLenFavFactor<S>
where
S: HasCorpus + HasMetadata,
S::Input: HasLen,
<S::Corpus as Corpus>::Input: HasLen,
{
phantom: PhantomData<S>,
}
@ -85,9 +87,9 @@ where
impl<S> TestcaseScore<S> for MaxExecsLenFavFactor<S>
where
S: HasCorpus + HasMetadata,
S::Input: HasLen,
<<S as HasCorpus>::Corpus as libafl::corpus::Corpus>::Input: HasLen
{
fn compute( state: &S, entry: &mut Testcase<S::Input>) -> Result<f64, Error> {
fn compute( state: &S, entry: &mut Testcase<<S::Corpus as Corpus>::Input>) -> Result<f64, Error> {
let execs_per_hour = (3600.0/entry.exec_time().expect("testcase.exec_time is needed for scheduler").as_secs_f64());
let execs_times_length_per_hour = execs_per_hour*entry.load_len(state.corpus()).unwrap() as f64;
Ok(execs_times_length_per_hour)
@ -102,17 +104,17 @@ pub struct SortedFeedback {
name: Cow<'static, str>
}
impl<S> Feedback<S> for SortedFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for SortedFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
S::Input: HasTargetBytes,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
_observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -176,16 +178,16 @@ pub struct ExecTimeReachedFeedback
target_time: u64,
}
impl<S> Feedback<S> for ExecTimeReachedFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for ExecTimeReachedFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -226,16 +228,16 @@ pub struct ExecTimeCollectorFeedback
name: Cow<'static, str>
}
impl<S> Feedback<S> for ExecTimeCollectorFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for ExecTimeCollectorFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -298,16 +300,16 @@ pub struct ExecTimeIncFeedback
last_is_longest: bool
}
impl<S> Feedback<S> for ExecTimeIncFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for ExecTimeIncFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -326,7 +328,7 @@ where
Ok(false)
}
}
fn append_metadata<EM, OT>(
fn append_metadata(
&mut self,
_state: &mut S,
_manager: &mut EM,
@ -368,16 +370,16 @@ pub struct AlwaysTrueFeedback
name: Cow<'static, str>
}
impl<S> Feedback<S> for AlwaysTrueFeedback
impl<EM, I, OT, S> Feedback<EM, I, OT, S> for AlwaysTrueFeedback
where
S: State + UsesInput + MaybeHasClientPerfMonitor,
{
#[allow(clippy::wrong_self_convention)]
fn is_interesting<EM, OT>(
fn is_interesting(
&mut self,
_state: &mut S,
_manager: &mut EM,
_input: &S::Input,
_input: &I,
_observers: &OT,
_exit_kind: &ExitKind,
) -> Result<bool, Error>
@ -413,7 +415,7 @@ where
//=========================== Probability Mass Scheduler
pub type TimeProbMassScheduler<S> =
ProbabilitySamplingScheduler<TimeProbFactor<S>, S>;
ProbabilitySamplingScheduler<TimeProbFactor<S>>;
#[derive(Debug, Clone)]
pub struct TimeProbFactor<S>

View File

@ -44,7 +44,7 @@ where
fn init<E: HasObservers>(&mut self, _state: &mut S) {}
/// Call before running a target.
fn pre_exec(&mut self, _state: &mut S, _input: &S::Input) {
fn pre_exec(&mut self, _state: &mut S, _input: &<S as UsesInput>::Input) {
unsafe {
let data = &raw mut FORK_EXECUTOR_GLOBAL_DATA;
(*data).crash_handler = self.crash_handler;
@ -53,7 +53,7 @@ where
}
}
fn post_exec(&mut self, _state: &mut S, _input: &S::Input) {}
fn post_exec(&mut self, _state: &mut S, _input: &<S as UsesInput>::Input) {}
}
impl<S> InChildProcessHooks<S> {