Ignore SigPipe by default (#1741)
* Ignore SigPipe by default * Fix no_std * fmt
This commit is contained in:
parent
c93291ab57
commit
16a152267e
@ -56,6 +56,8 @@ fork = ["libafl_bolts/derive"]
|
||||
## Collected stats to decide if observers must be serialized or not (which should reduce mem use and increase speed)
|
||||
adaptive_serialization = []
|
||||
|
||||
## If this feature is set, `LibAFL` targets (and the fuzzer) will crash on `SIGPIPE` on unix systems.
|
||||
handle_sigpipe = []
|
||||
|
||||
#! ## Additional Components
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#![allow(clippy::needless_pass_by_value)]
|
||||
|
||||
use alloc::boxed::Box;
|
||||
#[cfg(all(unix, feature = "std"))]
|
||||
#[cfg(unix)]
|
||||
use alloc::vec::Vec;
|
||||
#[cfg(all(feature = "std", unix, target_os = "linux"))]
|
||||
use core::ptr::addr_of_mut;
|
||||
@ -28,8 +28,10 @@ use std::intrinsics::transmute;
|
||||
|
||||
#[cfg(all(unix, not(miri)))]
|
||||
use libafl_bolts::os::unix_signals::setup_signal_handler;
|
||||
#[cfg(unix)]
|
||||
use libafl_bolts::os::unix_signals::Signal;
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
use libafl_bolts::os::unix_signals::{ucontext_t, Handler, Signal};
|
||||
use libafl_bolts::os::unix_signals::{ucontext_t, Handler};
|
||||
#[cfg(all(windows, feature = "std"))]
|
||||
use libafl_bolts::os::windows_exceptions::setup_exception_handler;
|
||||
#[cfg(all(feature = "std", unix))]
|
||||
@ -276,6 +278,24 @@ pub struct InProcessHandlers {
|
||||
pub timeout_handler: *const c_void,
|
||||
}
|
||||
|
||||
/// The common signals we want to handle
|
||||
#[cfg(unix)]
|
||||
#[inline]
|
||||
fn common_signals() -> Vec<Signal> {
|
||||
vec![
|
||||
Signal::SigAlarm,
|
||||
Signal::SigUser2,
|
||||
Signal::SigAbort,
|
||||
Signal::SigBus,
|
||||
#[cfg(feature = "handle_sigpipe")]
|
||||
Signal::SigPipe,
|
||||
Signal::SigFloatingPointException,
|
||||
Signal::SigIllegalInstruction,
|
||||
Signal::SigSegmentationFault,
|
||||
Signal::SigTrap,
|
||||
]
|
||||
}
|
||||
|
||||
impl InProcessHandlers {
|
||||
/// Call before running a target.
|
||||
#[allow(clippy::unused_self)]
|
||||
@ -683,6 +703,7 @@ pub mod unix_signal_handler {
|
||||
use libafl_bolts::os::unix_signals::{ucontext_t, Handler, Signal};
|
||||
use libc::siginfo_t;
|
||||
|
||||
use super::common_signals;
|
||||
#[cfg(feature = "std")]
|
||||
use crate::inputs::Input;
|
||||
use crate::{
|
||||
@ -743,17 +764,7 @@ pub mod unix_signal_handler {
|
||||
}
|
||||
|
||||
fn signals(&self) -> Vec<Signal> {
|
||||
vec![
|
||||
Signal::SigAlarm,
|
||||
Signal::SigUser2,
|
||||
Signal::SigAbort,
|
||||
Signal::SigBus,
|
||||
Signal::SigPipe,
|
||||
Signal::SigFloatingPointException,
|
||||
Signal::SigIllegalInstruction,
|
||||
Signal::SigSegmentationFault,
|
||||
Signal::SigTrap,
|
||||
]
|
||||
common_signals()
|
||||
}
|
||||
}
|
||||
|
||||
@ -1541,17 +1552,7 @@ impl Handler for InProcessForkExecutorGlobalData {
|
||||
}
|
||||
|
||||
fn signals(&self) -> Vec<Signal> {
|
||||
vec![
|
||||
Signal::SigAlarm,
|
||||
Signal::SigUser2,
|
||||
Signal::SigAbort,
|
||||
Signal::SigBus,
|
||||
Signal::SigPipe,
|
||||
Signal::SigFloatingPointException,
|
||||
Signal::SigIllegalInstruction,
|
||||
Signal::SigSegmentationFault,
|
||||
Signal::SigTrap,
|
||||
]
|
||||
common_signals()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -331,16 +331,6 @@ impl From<Signal> for nix::sys::signal::Signal {
|
||||
}
|
||||
}
|
||||
|
||||
/// A list of crashing signals
|
||||
pub static CRASH_SIGNALS: &[Signal] = &[
|
||||
Signal::SigAbort,
|
||||
Signal::SigBus,
|
||||
Signal::SigFloatingPointException,
|
||||
Signal::SigIllegalInstruction,
|
||||
Signal::SigPipe,
|
||||
Signal::SigSegmentationFault,
|
||||
];
|
||||
|
||||
impl PartialEq for Signal {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
*self as i32 == *other as i32
|
||||
|
Loading…
x
Reference in New Issue
Block a user