Skip to content

Commit 723f4a1

Browse files
authored
Fix various QEMU bugs (#2475)
* Update LibAFL QEMU to the latest version (V9.0.2 update, important bug fixes, ... - check the dedicated repo for more info) * fix bug in hook execution, causing first execution hooks to be run multiple times.
1 parent 3bebbe0 commit 723f4a1

File tree

6 files changed

+16
-10
lines changed

6 files changed

+16
-10
lines changed

.dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
target
1+
**/target
2+
**/.git
23
Cargo.lock
34

45
*.o

fuzzers/qemu/qemu_launcher/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ vergen = { version = "8.2", features = [
4848

4949
[dependencies]
5050
clap = { version = "4.3", features = ["derive", "string"] }
51-
libafl = { path = "../../../libafl/" }
52-
libafl_bolts = { path = "../../../libafl_bolts/", features = [
51+
libafl = { path = "../../../libafl" }
52+
libafl_bolts = { path = "../../../libafl_bolts", features = [
5353
"errors_backtrace",
5454
] }
55-
libafl_qemu = { path = "../../../libafl_qemu/", features = ["usermode"] }
55+
libafl_qemu = { path = "../../../libafl_qemu", features = ["usermode"] }
5656
log = { version = "0.4.20" }
5757
nix = { version = "0.29", features = ["fs"] }
5858
rangemap = { version = "1.3" }
5959
readonly = { version = "0.2.10" }
60-
typed-builder = { version = "0.18" }
60+
typed-builder = { version = "0.19" }

libafl_qemu/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ serde_yaml = { version = "0.9", optional = true } # For parsing the injections y
125125
toml = { version = "0.8.13", optional = true } # For parsing the injections toml file
126126
pyo3 = { version = "0.22", optional = true, features = ["multiple-pymethods"] }
127127
bytes-utils = "0.1"
128-
typed-builder = "0.18"
128+
typed-builder = "0.19"
129129
memmap2 = "0.9"
130130
# Document all features of this crate (for `cargo doc`)
131131
document-features = { version = "0.2", optional = true }

libafl_qemu/libafl_qemu_build/src/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::cargo_add_rpath;
1111

1212
pub const QEMU_URL: &str = "https://github.com/AFLplusplus/qemu-libafl-bridge";
1313
pub const QEMU_DIRNAME: &str = "qemu-libafl-bridge";
14-
pub const QEMU_REVISION: &str = "4cafaa9a087dae6674b0fdc11ba34d3e6a8364d2";
14+
pub const QEMU_REVISION: &str = "24abc2a717226bedc047167f639aef0edc9ce92d";
1515

1616
#[allow(clippy::module_name_repetitions)]
1717
pub struct BuildResult {

libafl_qemu/src/emu/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,7 @@ where
477477
breakpoints_by_id: RefCell<HashMap<BreakpointId, BreakpointMutRef<CM, EH, ET, S>>>,
478478
#[builder(setter(transform = |args: &[String], env: &[(String, String)]| Qemu::init(args, env).unwrap()))]
479479
qemu: Qemu,
480+
first_exec: bool,
480481
_phantom: PhantomData<(ET, S)>,
481482
}
482483

@@ -513,6 +514,7 @@ where
513514
exit_handler: RefCell::new(exit_handler),
514515
breakpoints_by_addr: RefCell::new(HashMap::new()),
515516
breakpoints_by_id: RefCell::new(HashMap::new()),
517+
first_exec: true,
516518
_phantom: PhantomData,
517519
qemu,
518520
})
@@ -678,7 +680,10 @@ where
678680
}
679681

680682
pub fn first_exec_all(&mut self) {
681-
self.modules.first_exec_all();
683+
if self.first_exec {
684+
self.modules.first_exec_all();
685+
self.first_exec = false;
686+
}
682687
}
683688

684689
pub fn pre_exec_all(&mut self, input: &S::Input) {

libafl_qemu/src/modules/edges.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ where
162162
ET: EmulatorModuleTuple<S>,
163163
{
164164
if self.use_hitcounts {
165-
// hooks.edges(
165+
// emulator_modules.edges(
166166
// Hook::Function(gen_unique_edge_ids::<ET, S>),
167167
// Hook::Raw(trace_edge_hitcount),
168168
// );
@@ -175,7 +175,7 @@ where
175175
);
176176
}
177177
} else {
178-
// hooks.edges(
178+
// emulator_modules.edges(
179179
// Hook::Function(gen_unique_edge_ids::<ET, S>),
180180
// Hook::Raw(trace_edge_single),
181181
// );

0 commit comments

Comments
 (0)