Properly use in_handler (#2957)

* properly use it

* a

* a

* typo
This commit is contained in:
Dongjia "toka" Zhang 2025-02-09 15:08:09 +01:00 committed by GitHub
parent 83d88546d3
commit 89e470250f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 13 deletions

View File

@ -48,18 +48,11 @@ use libafl_bolts::{
use libafl_qemu::{ use libafl_qemu::{
elf::EasyElf, elf::EasyElf,
filter_qemu_args, filter_qemu_args,
// asan::{init_with_asan, QemuAsanHelper}, modules::{
modules::cmplog::{CmpLogModule, CmpLogObserver}, cmplog::{CmpLogModule, CmpLogObserver},
modules::edges::StdEdgeCoverageModule, edges::StdEdgeCoverageModule,
modules::AsanModule, },
Emulator, Emulator, GuestReg, MmapPerms, QemuExecutor, QemuExitError, QemuExitReason, QemuShutdownCause,
GuestReg,
//snapshot::QemuSnapshotHelper,
MmapPerms,
QemuExecutor,
QemuExitError,
QemuExitReason,
QemuShutdownCause,
Regs, Regs,
}; };
use libafl_targets::{edges_map_mut_ptr, EDGES_MAP_ALLOCATED_SIZE, MAX_EDGES_FOUND}; use libafl_targets::{edges_map_mut_ptr, EDGES_MAP_ALLOCATED_SIZE, MAX_EDGES_FOUND};

View File

@ -52,6 +52,12 @@ pub mod unix_signal_handler {
unsafe { unsafe {
let data = &raw mut GLOBAL_STATE; let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true); let in_handler = (*data).set_in_handler(true);
assert!(
!in_handler,
"We crashed inside a crash handler, but this should never happen!"
);
match signal { match signal {
Signal::SigUser2 | Signal::SigAlarm => { Signal::SigUser2 | Signal::SigAlarm => {
if !(*data).timeout_handler.is_null() { if !(*data).timeout_handler.is_null() {
@ -91,6 +97,12 @@ pub mod unix_signal_handler {
old_hook(panic_info); old_hook(panic_info);
let data = &raw mut GLOBAL_STATE; let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true); let in_handler = (*data).set_in_handler(true);
assert!(
!in_handler,
"We crashed inside a crash panic hook, but this should never happen!"
);
if (*data).is_valid() { if (*data).is_valid() {
// We are fuzzing! // We are fuzzing!
let executor = (*data).executor_mut::<E>(); let executor = (*data).executor_mut::<E>();

View File

@ -34,7 +34,13 @@ pub mod windows_asan_handler {
Z: HasObjective<Objective = OF>, Z: HasObjective<Objective = OF>,
{ {
let data = &raw mut GLOBAL_STATE; let data = &raw mut GLOBAL_STATE;
(*data).set_in_handler(true); let in_handler = (*data).set_in_handler(true);
assert!(
!in_handler,
"We crashed inside a asan death handler, but this should never happen!"
);
// Have we set a timer_before? // Have we set a timer_before?
if (*data).ptp_timer.is_some() { if (*data).ptp_timer.is_some() {
/* /*
@ -159,6 +165,12 @@ pub mod windows_exception_handler {
unsafe { unsafe {
let data = &raw mut GLOBAL_STATE; let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true); let in_handler = (*data).set_in_handler(true);
assert!(
!in_handler,
"We crashed inside a crash handler, but this should never happen!"
);
if !(*data).crash_handler.is_null() { if !(*data).crash_handler.is_null() {
let func: HandlerFuncPtr = transmute((*data).crash_handler); let func: HandlerFuncPtr = transmute((*data).crash_handler);
(func)(exception_pointers, data); (func)(exception_pointers, data);
@ -193,6 +205,12 @@ pub mod windows_exception_handler {
panic::set_hook(Box::new(move |panic_info| unsafe { panic::set_hook(Box::new(move |panic_info| unsafe {
let data = &raw mut GLOBAL_STATE; let data = &raw mut GLOBAL_STATE;
let in_handler = (*data).set_in_handler(true); let in_handler = (*data).set_in_handler(true);
assert!(
!in_handler,
"We crashed inside a panic hook, but this should never happen!"
);
// Have we set a timer_before? // Have we set a timer_before?
if (*data).ptp_timer.is_some() { if (*data).ptp_timer.is_some() {
/* /*