Skip to content

Commit 3b31b4d

Browse files
authored
libafl_qemu: unset thumb bit for breakpoints (AFLplusplus#2619)
* unset thumb bit for breakpoints
1 parent 23e966c commit 3b31b4d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

libafl_qemu/src/qemu/mod.rs

+14
Original file line numberDiff line numberDiff line change
@@ -825,12 +825,26 @@ impl Qemu {
825825
}
826826

827827
pub fn set_breakpoint(&self, addr: GuestAddr) {
828+
// Remove thumb bit encoded in addresses.
829+
// Since ARMv7, instructions are (half-)word aligned, so this is safe.
830+
// For ARMv6 and before, this could be wrong since SCTLR.U could be 0.
831+
// TODO: check precisely for architecture before doing this.
832+
#[cfg(target_arch = "arm")]
833+
let addr = { addr & !1 };
834+
828835
unsafe {
829836
libafl_qemu_set_breakpoint(addr.into());
830837
}
831838
}
832839

833840
pub fn remove_breakpoint(&self, addr: GuestAddr) {
841+
// Remove thumb bit encoded in addresses.
842+
// Since ARMv7, instructions are (half-)word aligned, so this is safe.
843+
// For ARMv6 and before, this could be wrong since SCTLR.U could be 0.
844+
// TODO: check precisely for architecture before doing this.
845+
#[cfg(target_arch = "arm")]
846+
let addr = { addr & !1 };
847+
834848
unsafe {
835849
libafl_qemu_remove_breakpoint(addr.into());
836850
}

0 commit comments

Comments
 (0)