Skip to content

Commit

Permalink
Qemu launcher bugfix (#2858)
Browse files Browse the repository at this point in the history
* Fixed the issue where compilation failed under the simplemgr configuration.

* Fixed the issue where the crash handler would fail during rerun.

* update fmt

---------

Co-authored-by: h1k0 <[email protected]>
  • Loading branch information
noobone123 and h1k0 authored Jan 20, 2025
1 parent a949452 commit 9a64a53
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
17 changes: 10 additions & 7 deletions fuzzers/binary_only/qemu_launcher/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ use libafl::{
Error,
};
use libafl_bolts::{rands::StdRand, tuples::tuple_list};
#[cfg(feature = "injections")]
use libafl_qemu::modules::injections::InjectionModule;
use libafl_qemu::modules::{
asan::AsanModule, asan_guest::AsanGuestModule, cmplog::CmpLogModule, DrCovModule,
InjectionModule,
};

use crate::{
Expand Down Expand Up @@ -75,7 +74,7 @@ impl Client<'_> {
}

#[cfg(not(feature = "injections"))]
let injection_module = None;
let injection_module = Option::<InjectionModule>::None;

#[cfg(feature = "injections")]
let injection_module = self
Expand All @@ -95,10 +94,14 @@ impl Client<'_> {

let is_cmplog = self.options.is_cmplog_core(core_id);

let extra_tokens = injection_module
.as_ref()
.map(|h| h.tokens.clone())
.unwrap_or_default();
let extra_tokens = if cfg!(feature = "injections") {
injection_module
.as_ref()
.map(|h| h.tokens.clone())
.unwrap_or_default()
} else {
Vec::new()
};

let instance_builder = Instance::builder()
.options(self.options)
Expand Down
6 changes: 5 additions & 1 deletion fuzzers/binary_only/qemu_launcher/src/fuzzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,11 @@ impl Fuzzer {
}

#[cfg(feature = "simplemgr")]
return client.run(None, SimpleEventManager::new(monitor), CoreId(0));
return client.run(
None,
SimpleEventManager::new(monitor),
ClientDescription::new(0, 0, CoreId(0)),
);

// Build and run the Launcher / fuzzer.
#[cfg(not(feature = "simplemgr"))]
Expand Down
9 changes: 2 additions & 7 deletions fuzzers/binary_only/qemu_launcher/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ pub type ClientState =
StdState<InMemoryOnDiskCorpus<BytesInput>, BytesInput, StdRand, OnDiskCorpus<BytesInput>>;

#[cfg(feature = "simplemgr")]
pub type ClientMgr<M> = SimpleEventManager<M, ClientState>;
pub type ClientMgr<M> = SimpleEventManager<BytesInput, M, ClientState>;
#[cfg(not(feature = "simplemgr"))]
pub type ClientMgr<M> = MonitorTypedEventManager<
LlmpRestartingEventManager<(), BytesInput, ClientState, StdShMemProvider>,
Expand Down Expand Up @@ -242,12 +242,7 @@ impl<M: Monitor> Instance<'_, M> {
)?;

executor
.run_target(
&mut NopFuzzer::new(),
&mut state,
&mut NopEventManager::new(),
&input,
)
.run_target(&mut fuzzer, &mut state, &mut self.mgr, &input)
.expect("Error running target");
// We're done :)
process::exit(0);
Expand Down

0 comments on commit 9a64a53

Please sign in to comment.