More docs and less pub types (#646)
* more docs * nits * fixes * win fix * fmt
This commit is contained in:
parent
b7650f7683
commit
fa839bb08d
@ -27,9 +27,7 @@ use libafl::{
|
|||||||
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
|
mutators::scheduled::{havoc_mutations, tokens_mutations, StdScheduledMutator},
|
||||||
mutators::token_mutations::Tokens,
|
mutators::token_mutations::Tokens,
|
||||||
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
|
observers::{HitcountsMapObserver, StdMapObserver, TimeObserver},
|
||||||
schedulers::{
|
schedulers::{IndexesLenTimeMinimizerScheduler, StdWeightedScheduler},
|
||||||
powersched::PowerSchedule, IndexesLenTimeMinimizerScheduler, StdWeightedScheduler,
|
|
||||||
},
|
|
||||||
stages::{calibrate::CalibrationStage, power::StdPowerMutationalStage},
|
stages::{calibrate::CalibrationStage, power::StdPowerMutationalStage},
|
||||||
state::{HasCorpus, HasMetadata, StdState},
|
state::{HasCorpus, HasMetadata, StdState},
|
||||||
Error,
|
Error,
|
||||||
|
@ -384,15 +384,18 @@ impl InProcessHandlers {
|
|||||||
|
|
||||||
/// The global state of the in-process harness.
|
/// The global state of the in-process harness.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(missing_docs)]
|
pub(crate) struct InProcessExecutorHandlerData {
|
||||||
pub struct InProcessExecutorHandlerData {
|
state_ptr: *mut c_void,
|
||||||
pub state_ptr: *mut c_void,
|
event_mgr_ptr: *mut c_void,
|
||||||
pub event_mgr_ptr: *mut c_void,
|
fuzzer_ptr: *mut c_void,
|
||||||
pub fuzzer_ptr: *mut c_void,
|
executor_ptr: *const c_void,
|
||||||
pub executor_ptr: *const c_void,
|
|
||||||
pub current_input_ptr: *const c_void,
|
pub current_input_ptr: *const c_void,
|
||||||
pub crash_handler: *const c_void,
|
/// The timeout handler
|
||||||
pub timeout_handler: *const c_void,
|
#[allow(unused)] // for no_std
|
||||||
|
crash_handler: *const c_void,
|
||||||
|
/// The timeout handler
|
||||||
|
#[allow(unused)] // for no_std
|
||||||
|
timeout_handler: *const c_void,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
pub tp_timer: *mut c_void,
|
pub tp_timer: *mut c_void,
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
@ -446,7 +449,7 @@ impl InProcessExecutorHandlerData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Exception handling needs some nasty unsafe.
|
/// Exception handling needs some nasty unsafe.
|
||||||
pub static mut GLOBAL_STATE: InProcessExecutorHandlerData = InProcessExecutorHandlerData {
|
pub(crate) static mut GLOBAL_STATE: InProcessExecutorHandlerData = InProcessExecutorHandlerData {
|
||||||
/// The state ptr for signal handling
|
/// The state ptr for signal handling
|
||||||
state_ptr: ptr::null_mut(),
|
state_ptr: ptr::null_mut(),
|
||||||
/// The event manager ptr for signal handling
|
/// The event manager ptr for signal handling
|
||||||
@ -527,7 +530,7 @@ mod unix_signal_handler {
|
|||||||
state::{HasClientPerfMonitor, HasMetadata, HasSolutions},
|
state::{HasClientPerfMonitor, HasMetadata, HasSolutions},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type HandlerFuncPtr =
|
pub(crate) type HandlerFuncPtr =
|
||||||
unsafe fn(Signal, siginfo_t, &mut ucontext_t, data: &mut InProcessExecutorHandlerData);
|
unsafe fn(Signal, siginfo_t, &mut ucontext_t, data: &mut InProcessExecutorHandlerData);
|
||||||
|
|
||||||
/// A handler that does nothing.
|
/// A handler that does nothing.
|
||||||
@ -649,7 +652,7 @@ mod unix_signal_handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub unsafe fn inproc_timeout_handler<E, EM, I, OF, OT, S, Z>(
|
pub(crate) unsafe fn inproc_timeout_handler<E, EM, I, OF, OT, S, Z>(
|
||||||
_signal: Signal,
|
_signal: Signal,
|
||||||
_info: siginfo_t,
|
_info: siginfo_t,
|
||||||
_context: &mut ucontext_t,
|
_context: &mut ucontext_t,
|
||||||
@ -729,7 +732,7 @@ mod unix_signal_handler {
|
|||||||
/// Will be used for signal handling.
|
/// Will be used for signal handling.
|
||||||
/// It will store the current State to shmem, then exit.
|
/// It will store the current State to shmem, then exit.
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
pub(crate) unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
||||||
signal: Signal,
|
signal: Signal,
|
||||||
_info: siginfo_t,
|
_info: siginfo_t,
|
||||||
_context: &mut ucontext_t,
|
_context: &mut ucontext_t,
|
||||||
@ -880,7 +883,8 @@ mod windows_exception_handler {
|
|||||||
use core::sync::atomic::{compiler_fence, Ordering};
|
use core::sync::atomic::{compiler_fence, Ordering};
|
||||||
use windows::Win32::System::Threading::ExitProcess;
|
use windows::Win32::System::Threading::ExitProcess;
|
||||||
|
|
||||||
pub type HandlerFuncPtr = unsafe fn(*mut EXCEPTION_POINTERS, &mut InProcessExecutorHandlerData);
|
pub(crate) type HandlerFuncPtr =
|
||||||
|
unsafe fn(*mut EXCEPTION_POINTERS, &mut InProcessExecutorHandlerData);
|
||||||
|
|
||||||
/*pub unsafe fn nop_handler(
|
/*pub unsafe fn nop_handler(
|
||||||
_code: ExceptionCode,
|
_code: ExceptionCode,
|
||||||
@ -1104,7 +1108,7 @@ mod windows_exception_handler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_lines)]
|
#[allow(clippy::too_many_lines)]
|
||||||
pub unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
pub(crate) unsafe fn inproc_crash_handler<E, EM, I, OF, OT, S, Z>(
|
||||||
exception_pointers: *mut EXCEPTION_POINTERS,
|
exception_pointers: *mut EXCEPTION_POINTERS,
|
||||||
data: &mut InProcessExecutorHandlerData,
|
data: &mut InProcessExecutorHandlerData,
|
||||||
) where
|
) where
|
||||||
@ -1244,7 +1248,7 @@ mod windows_exception_handler {
|
|||||||
|
|
||||||
/// The signature of the crash handler function
|
/// The signature of the crash handler function
|
||||||
#[cfg(all(feature = "std", unix))]
|
#[cfg(all(feature = "std", unix))]
|
||||||
pub type ForkHandlerFuncPtr =
|
pub(crate) type ForkHandlerFuncPtr =
|
||||||
unsafe fn(Signal, siginfo_t, &mut ucontext_t, data: &mut InProcessForkExecutorGlobalData);
|
unsafe fn(Signal, siginfo_t, &mut ucontext_t, data: &mut InProcessForkExecutorGlobalData);
|
||||||
|
|
||||||
/// The inmem fork executor's handlers.
|
/// The inmem fork executor's handlers.
|
||||||
@ -1306,7 +1310,7 @@ impl InChildProcessHandlers {
|
|||||||
/// The global state of the in-process-fork harness.
|
/// The global state of the in-process-fork harness.
|
||||||
#[cfg(all(feature = "std", unix))]
|
#[cfg(all(feature = "std", unix))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct InProcessForkExecutorGlobalData {
|
pub(crate) struct InProcessForkExecutorGlobalData {
|
||||||
/// Stores a pointer to the fork executor struct
|
/// Stores a pointer to the fork executor struct
|
||||||
pub executor_ptr: *const c_void,
|
pub executor_ptr: *const c_void,
|
||||||
/// Stores a pointer to the state
|
/// Stores a pointer to the state
|
||||||
@ -1349,7 +1353,7 @@ impl InProcessForkExecutorGlobalData {
|
|||||||
|
|
||||||
/// a static variable storing the global state
|
/// a static variable storing the global state
|
||||||
#[cfg(all(feature = "std", unix))]
|
#[cfg(all(feature = "std", unix))]
|
||||||
pub static mut FORK_EXECUTOR_GLOBAL_DATA: InProcessForkExecutorGlobalData =
|
pub(crate) static mut FORK_EXECUTOR_GLOBAL_DATA: InProcessForkExecutorGlobalData =
|
||||||
InProcessForkExecutorGlobalData {
|
InProcessForkExecutorGlobalData {
|
||||||
executor_ptr: ptr::null(),
|
executor_ptr: ptr::null(),
|
||||||
crash_handler: ptr::null(),
|
crash_handler: ptr::null(),
|
||||||
@ -1591,7 +1595,7 @@ pub mod child_signal_handlers {
|
|||||||
/// The function should only be called from a child crash handler.
|
/// The function should only be called from a child crash handler.
|
||||||
/// It will dereference the `data` pointer and assume it's valid.
|
/// It will dereference the `data` pointer and assume it's valid.
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
pub unsafe fn child_crash_handler<E, I, OT, S>(
|
pub(crate) unsafe fn child_crash_handler<E, I, OT, S>(
|
||||||
_signal: Signal,
|
_signal: Signal,
|
||||||
_info: siginfo_t,
|
_info: siginfo_t,
|
||||||
_context: &mut ucontext_t,
|
_context: &mut ucontext_t,
|
||||||
|
@ -68,8 +68,8 @@ where
|
|||||||
|
|
||||||
/// The metadata used for `gramatron`
|
/// The metadata used for `gramatron`
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
#[allow(missing_docs)]
|
|
||||||
pub struct GramatronIdxMapMetadata {
|
pub struct GramatronIdxMapMetadata {
|
||||||
|
/// The map containing a vec for each terminal
|
||||||
pub map: HashMap<usize, Vec<usize>>,
|
pub map: HashMap<usize, Vec<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,14 +129,19 @@ impl SchedulerMetadata {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The power schedule to use
|
/// The power schedule to use
|
||||||
#[allow(missing_docs)]
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
pub enum PowerSchedule {
|
pub enum PowerSchedule {
|
||||||
|
/// The `explore" power schedule
|
||||||
EXPLORE,
|
EXPLORE,
|
||||||
|
/// The `exploit` power schedule
|
||||||
EXPLOIT,
|
EXPLOIT,
|
||||||
|
/// The `fast` power schedule
|
||||||
FAST,
|
FAST,
|
||||||
|
/// The `coe` power schedule
|
||||||
COE,
|
COE,
|
||||||
|
/// The `lin` power schedule
|
||||||
LIN,
|
LIN,
|
||||||
|
/// The `quad` power schedule
|
||||||
QUAD,
|
QUAD,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,20 +27,31 @@ use crate::asan::errors::{AsanError, AsanErrors};
|
|||||||
|
|
||||||
/// An allocator wrapper with binary-only address sanitization
|
/// An allocator wrapper with binary-only address sanitization
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[allow(missing_docs)]
|
|
||||||
pub struct Allocator {
|
pub struct Allocator {
|
||||||
|
/// The fuzzer options
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
options: FuzzerOptions,
|
options: FuzzerOptions,
|
||||||
|
/// The page size
|
||||||
page_size: usize,
|
page_size: usize,
|
||||||
|
/// The shadow offsets
|
||||||
shadow_offset: usize,
|
shadow_offset: usize,
|
||||||
|
/// The shadow bit
|
||||||
shadow_bit: usize,
|
shadow_bit: usize,
|
||||||
|
/// If the shadow is pre-allocated
|
||||||
pre_allocated_shadow: bool,
|
pre_allocated_shadow: bool,
|
||||||
|
/// All tracked allocations
|
||||||
allocations: HashMap<usize, AllocationMetadata>,
|
allocations: HashMap<usize, AllocationMetadata>,
|
||||||
|
/// The shadow memory pages
|
||||||
shadow_pages: RangeSet<usize>,
|
shadow_pages: RangeSet<usize>,
|
||||||
|
/// A list of allocations
|
||||||
allocation_queue: BTreeMap<usize, Vec<AllocationMetadata>>,
|
allocation_queue: BTreeMap<usize, Vec<AllocationMetadata>>,
|
||||||
|
/// The size of the largest allocation
|
||||||
largest_allocation: usize,
|
largest_allocation: usize,
|
||||||
|
/// The total size of all allocations combined
|
||||||
total_allocation_size: usize,
|
total_allocation_size: usize,
|
||||||
|
/// The base address of the shadow memory
|
||||||
base_mapping_addr: usize,
|
base_mapping_addr: usize,
|
||||||
|
/// The current mapping address
|
||||||
current_mapping_addr: usize,
|
current_mapping_addr: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,14 +68,20 @@ macro_rules! map_to_shadow {
|
|||||||
|
|
||||||
/// Metadata for an allocation
|
/// Metadata for an allocation
|
||||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||||
#[allow(missing_docs)]
|
|
||||||
pub struct AllocationMetadata {
|
pub struct AllocationMetadata {
|
||||||
|
/// The address of the allocation
|
||||||
pub address: usize,
|
pub address: usize,
|
||||||
|
/// The size of the allocation
|
||||||
pub size: usize,
|
pub size: usize,
|
||||||
|
/// The actual allocated size, including metadata
|
||||||
pub actual_size: usize,
|
pub actual_size: usize,
|
||||||
|
/// A backtrace to the allocation location
|
||||||
pub allocation_site_backtrace: Option<Backtrace>,
|
pub allocation_site_backtrace: Option<Backtrace>,
|
||||||
|
/// A backtrace to the location where this memory has been released
|
||||||
pub release_site_backtrace: Option<Backtrace>,
|
pub release_site_backtrace: Option<Backtrace>,
|
||||||
|
/// If the allocation has been freed
|
||||||
pub freed: bool,
|
pub freed: bool,
|
||||||
|
/// If the allocation was done with a size of 0
|
||||||
pub is_malloc_zero: bool,
|
pub is_malloc_zero: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user