Change Qemu hook signature (#2527)
This commit is contained in:
parent
69941f258e
commit
4c5df53c6d
@ -1118,17 +1118,17 @@ where
|
|||||||
modules
|
modules
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn first_exec_all(&mut self) {
|
pub fn first_exec_all(&mut self, state: &mut S) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.modules_mut()
|
self.modules_mut()
|
||||||
.first_exec_all(Self::emulator_modules_mut_unchecked());
|
.first_exec_all(Self::emulator_modules_mut_unchecked(), state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pre_exec_all(&mut self, input: &S::Input) {
|
pub fn pre_exec_all(&mut self, input: &S::Input, state: &mut S) {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.modules_mut()
|
self.modules_mut()
|
||||||
.pre_exec_all(Self::emulator_modules_mut_unchecked(), input);
|
.pre_exec_all(Self::emulator_modules_mut_unchecked(), input, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1136,6 +1136,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
input: &S::Input,
|
input: &S::Input,
|
||||||
observers: &mut OT,
|
observers: &mut OT,
|
||||||
|
state: &mut S,
|
||||||
exit_kind: &mut ExitKind,
|
exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
@ -1145,6 +1146,7 @@ where
|
|||||||
Self::emulator_modules_mut_unchecked(),
|
Self::emulator_modules_mut_unchecked(),
|
||||||
input,
|
input,
|
||||||
observers,
|
observers,
|
||||||
|
state,
|
||||||
exit_kind,
|
exit_kind,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -338,26 +338,28 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn first_exec_all(&mut self) {
|
pub fn first_exec_all(&mut self, state: &mut S) {
|
||||||
if self.first_exec {
|
if self.first_exec {
|
||||||
self.modules.first_exec_all();
|
self.modules.first_exec_all(state);
|
||||||
self.first_exec = false;
|
self.first_exec = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pre_exec_all(&mut self, input: &S::Input) {
|
pub fn pre_exec_all(&mut self, input: &S::Input, state: &mut S) {
|
||||||
self.modules.pre_exec_all(input);
|
self.modules.pre_exec_all(input, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn post_exec_all<OT>(
|
pub fn post_exec_all<OT>(
|
||||||
&mut self,
|
&mut self,
|
||||||
input: &S::Input,
|
input: &S::Input,
|
||||||
observers: &mut OT,
|
observers: &mut OT,
|
||||||
|
state: &mut S,
|
||||||
exit_kind: &mut ExitKind,
|
exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
{
|
{
|
||||||
self.modules.post_exec_all(input, observers, exit_kind);
|
self.modules
|
||||||
|
.post_exec_all(input, observers, state, exit_kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,15 +205,20 @@ where
|
|||||||
mgr: &mut EM,
|
mgr: &mut EM,
|
||||||
input: &Self::Input,
|
input: &Self::Input,
|
||||||
) -> Result<ExitKind, Error> {
|
) -> Result<ExitKind, Error> {
|
||||||
self.inner.exposed_executor_state_mut().first_exec_all();
|
self.inner
|
||||||
|
.exposed_executor_state_mut()
|
||||||
|
.first_exec_all(state);
|
||||||
|
|
||||||
self.inner.exposed_executor_state_mut().pre_exec_all(input);
|
self.inner
|
||||||
|
.exposed_executor_state_mut()
|
||||||
|
.pre_exec_all(input, state);
|
||||||
|
|
||||||
let mut exit_kind = self.inner.run_target(fuzzer, state, mgr, input)?;
|
let mut exit_kind = self.inner.run_target(fuzzer, state, mgr, input)?;
|
||||||
|
|
||||||
self.inner.exposed_executor_state.post_exec_all(
|
self.inner.exposed_executor_state.post_exec_all(
|
||||||
input,
|
input,
|
||||||
&mut *self.inner.inner.observers_mut(),
|
&mut *self.inner.inner.observers_mut(),
|
||||||
|
state,
|
||||||
&mut exit_kind,
|
&mut exit_kind,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -412,8 +412,12 @@ where
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, input: &S::Input)
|
fn pre_exec<ET>(
|
||||||
where
|
&mut self,
|
||||||
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
|
input: &S::Input,
|
||||||
|
_state: &mut S,
|
||||||
|
) where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
self.collectors
|
self.collectors
|
||||||
@ -427,6 +431,7 @@ where
|
|||||||
emulator_modules: &mut EmulatorModules<ET, S>,
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
input: &S::Input,
|
input: &S::Input,
|
||||||
observers: &mut OT,
|
observers: &mut OT,
|
||||||
|
_state: &mut S,
|
||||||
exit_kind: &mut ExitKind,
|
exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
|
@ -81,7 +81,7 @@ impl<S> EmulatorModule<S> for CmpLogModule
|
|||||||
where
|
where
|
||||||
S: Unpin + UsesInput + HasMetadata,
|
S: Unpin + UsesInput + HasMetadata,
|
||||||
{
|
{
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -124,7 +124,7 @@ where
|
|||||||
{
|
{
|
||||||
const HOOKS_DO_SIDE_EFFECTS: bool = false;
|
const HOOKS_DO_SIDE_EFFECTS: bool = false;
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -363,7 +363,7 @@ impl<S> EmulatorModule<S> for CmpLogRoutinesModule
|
|||||||
where
|
where
|
||||||
S: Unpin + UsesInput,
|
S: Unpin + UsesInput,
|
||||||
{
|
{
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
|
@ -157,7 +157,7 @@ impl<S> EmulatorModule<S> for EdgeCoverageModule
|
|||||||
where
|
where
|
||||||
S: Unpin + UsesInput + HasMetadata,
|
S: Unpin + UsesInput + HasMetadata,
|
||||||
{
|
{
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -308,7 +308,7 @@ where
|
|||||||
{
|
{
|
||||||
const HOOKS_DO_SIDE_EFFECTS: bool = false;
|
const HOOKS_DO_SIDE_EFFECTS: bool = false;
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -454,7 +454,7 @@ where
|
|||||||
{
|
{
|
||||||
const HOOKS_DO_SIDE_EFFECTS: bool = false;
|
const HOOKS_DO_SIDE_EFFECTS: bool = false;
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
|
@ -48,14 +48,18 @@ where
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, _emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, _emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_exec<ET>(&mut self, _emulator_modules: &mut EmulatorModules<ET, S>, _input: &S::Input)
|
fn pre_exec<ET>(
|
||||||
where
|
&mut self,
|
||||||
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
|
_input: &S::Input,
|
||||||
|
_state: &mut S,
|
||||||
|
) where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -65,6 +69,7 @@ where
|
|||||||
_emulator_modules: &mut EmulatorModules<ET, S>,
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
_observers: &mut OT,
|
_observers: &mut OT,
|
||||||
|
_state: &mut S,
|
||||||
_exit_kind: &mut ExitKind,
|
_exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
@ -84,14 +89,18 @@ where
|
|||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>;
|
ET: EmulatorModuleTuple<S>;
|
||||||
|
|
||||||
fn first_exec_all<ET>(&mut self, _emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec_all<ET>(
|
||||||
where
|
&mut self,
|
||||||
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
|
_state: &mut S,
|
||||||
|
) where
|
||||||
ET: EmulatorModuleTuple<S>;
|
ET: EmulatorModuleTuple<S>;
|
||||||
|
|
||||||
fn pre_exec_all<ET>(
|
fn pre_exec_all<ET>(
|
||||||
&mut self,
|
&mut self,
|
||||||
_emulator_modules: &mut EmulatorModules<ET, S>,
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
|
_state: &mut S,
|
||||||
) where
|
) where
|
||||||
ET: EmulatorModuleTuple<S>;
|
ET: EmulatorModuleTuple<S>;
|
||||||
|
|
||||||
@ -100,6 +109,7 @@ where
|
|||||||
_emulator_modules: &mut EmulatorModules<ET, S>,
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
_observers: &mut OT,
|
_observers: &mut OT,
|
||||||
|
_state: &mut S,
|
||||||
_exit_kind: &mut ExitKind,
|
_exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
@ -118,7 +128,7 @@ where
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_exec_all<ET>(&mut self, _emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec_all<ET>(&mut self, _emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -128,6 +138,7 @@ where
|
|||||||
&mut self,
|
&mut self,
|
||||||
_emulator_modules: &mut EmulatorModules<ET, S>,
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
|
_state: &mut S,
|
||||||
) where
|
) where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -138,6 +149,7 @@ where
|
|||||||
_emulator_modules: &mut EmulatorModules<ET, S>,
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
_observers: &mut OT,
|
_observers: &mut OT,
|
||||||
|
_state: &mut S,
|
||||||
_exit_kind: &mut ExitKind,
|
_exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
@ -162,20 +174,24 @@ where
|
|||||||
self.1.init_modules_all(emulator_modules);
|
self.1.init_modules_all(emulator_modules);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_exec_all<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec_all<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
self.0.first_exec(emulator_modules);
|
self.0.first_exec(emulator_modules, state);
|
||||||
self.1.first_exec_all(emulator_modules);
|
self.1.first_exec_all(emulator_modules, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_exec_all<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, input: &S::Input)
|
fn pre_exec_all<ET>(
|
||||||
where
|
&mut self,
|
||||||
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
|
input: &S::Input,
|
||||||
|
state: &mut S,
|
||||||
|
) where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
self.0.pre_exec(emulator_modules, input);
|
self.0.pre_exec(emulator_modules, input, state);
|
||||||
self.1.pre_exec_all(emulator_modules, input);
|
self.1.pre_exec_all(emulator_modules, input, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn post_exec_all<OT, ET>(
|
fn post_exec_all<OT, ET>(
|
||||||
@ -183,15 +199,16 @@ where
|
|||||||
emulator_modules: &mut EmulatorModules<ET, S>,
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
input: &S::Input,
|
input: &S::Input,
|
||||||
observers: &mut OT,
|
observers: &mut OT,
|
||||||
|
state: &mut S,
|
||||||
exit_kind: &mut ExitKind,
|
exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
self.0
|
self.0
|
||||||
.post_exec(emulator_modules, input, observers, exit_kind);
|
.post_exec(emulator_modules, input, observers, state, exit_kind);
|
||||||
self.1
|
self.1
|
||||||
.post_exec_all(emulator_modules, input, observers, exit_kind);
|
.post_exec_all(emulator_modules, input, observers, state, exit_kind);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,7 +940,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -975,8 +975,12 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _input: &S::Input)
|
fn pre_exec<ET>(
|
||||||
where
|
&mut self,
|
||||||
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
|
_input: &S::Input,
|
||||||
|
_state: &mut S,
|
||||||
|
) where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
if self.empty {
|
if self.empty {
|
||||||
@ -990,6 +994,7 @@ where
|
|||||||
emulator_modules: &mut EmulatorModules<ET, S>,
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
_observers: &mut OT,
|
_observers: &mut OT,
|
||||||
|
_state: &mut S,
|
||||||
exit_kind: &mut ExitKind,
|
exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
|
@ -273,7 +273,7 @@ impl<S> EmulatorModule<S> for AsanGuestModule
|
|||||||
where
|
where
|
||||||
S: Unpin + UsesInput,
|
S: Unpin + UsesInput,
|
||||||
{
|
{
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
S: Unpin + UsesInput,
|
S: Unpin + UsesInput,
|
||||||
|
@ -100,7 +100,7 @@ where
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
@ -124,6 +124,7 @@ where
|
|||||||
_emulator_modules: &mut EmulatorModules<ET, S>,
|
_emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
_input: &S::Input,
|
_input: &S::Input,
|
||||||
_observers: &mut OT,
|
_observers: &mut OT,
|
||||||
|
_state: &mut S,
|
||||||
_exit_kind: &mut ExitKind,
|
_exit_kind: &mut ExitKind,
|
||||||
) where
|
) where
|
||||||
OT: ObserversTuple<S>,
|
OT: ObserversTuple<S>,
|
||||||
|
@ -267,7 +267,7 @@ where
|
|||||||
emulator_modules.syscalls(Hook::Function(syscall_hook::<ET, S>));
|
emulator_modules.syscalls(Hook::Function(syscall_hook::<ET, S>));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>)
|
fn first_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _state: &mut S)
|
||||||
where
|
where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
|
@ -689,8 +689,12 @@ where
|
|||||||
emulator_modules.after_syscalls(Hook::Function(trace_mmap_snapshot::<ET, S>));
|
emulator_modules.after_syscalls(Hook::Function(trace_mmap_snapshot::<ET, S>));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pre_exec<ET>(&mut self, emulator_modules: &mut EmulatorModules<ET, S>, _input: &S::Input)
|
fn pre_exec<ET>(
|
||||||
where
|
&mut self,
|
||||||
|
emulator_modules: &mut EmulatorModules<ET, S>,
|
||||||
|
_input: &S::Input,
|
||||||
|
_state: &mut S,
|
||||||
|
) where
|
||||||
ET: EmulatorModuleTuple<S>,
|
ET: EmulatorModuleTuple<S>,
|
||||||
{
|
{
|
||||||
if self.empty {
|
if self.empty {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user