libafl_nyx: Add documentation to NyxSettings fields
This commit is contained in:
parent
44c841ffb1
commit
a0d4a5b240
@ -35,8 +35,6 @@ fn main() {
|
||||
// nyx stuff
|
||||
let settings = NyxSettings::builder()
|
||||
.cpu_id(0)
|
||||
.snap_mode(true)
|
||||
.parallel_mode(true)
|
||||
.parent_cpu_id(Some(parent_cpu_id.0 as u32))
|
||||
.build();
|
||||
let helper = NyxHelper::new("/tmp/nyx_libxml2/", settings).unwrap();
|
||||
|
@ -21,12 +21,7 @@ use libafl_nyx::{executor::NyxExecutor, helper::NyxHelper, settings::NyxSettings
|
||||
|
||||
fn main() {
|
||||
// nyx stuff
|
||||
let settings = NyxSettings::builder()
|
||||
.cpu_id(0)
|
||||
.snap_mode(true)
|
||||
.parallel_mode(false)
|
||||
.parent_cpu_id(None)
|
||||
.build();
|
||||
let settings = NyxSettings::builder().cpu_id(0).parent_cpu_id(None).build();
|
||||
let helper = NyxHelper::new("/tmp/nyx_libxml2/", settings).unwrap();
|
||||
let observer =
|
||||
unsafe { StdMapObserver::from_mut_ptr("trace", helper.bitmap_buffer, helper.bitmap_size) };
|
||||
|
@ -39,18 +39,10 @@ impl NyxHelper {
|
||||
.to_str()
|
||||
.ok_or(Error::illegal_argument("`work_dir` contains invalid UTF-8"))?;
|
||||
|
||||
let nyx_process_type = match (settings.parallel_mode, settings.parent_cpu_id) {
|
||||
(false, _) => NyxProcessType::ALONE,
|
||||
(true, Some(parent_cpu_id)) if settings.cpu_id == parent_cpu_id => {
|
||||
NyxProcessType::PARENT
|
||||
}
|
||||
(true, Some(_)) => NyxProcessType::CHILD,
|
||||
|
||||
(true, _) => {
|
||||
return Err(Error::illegal_argument(
|
||||
"`parent_cpu_id` is required in nyx parallel mode",
|
||||
))
|
||||
}
|
||||
let nyx_process_type = match settings.parent_cpu_id {
|
||||
None => NyxProcessType::ALONE,
|
||||
Some(parent_cpu_id) if settings.cpu_id == parent_cpu_id => NyxProcessType::PARENT,
|
||||
_ => NyxProcessType::CHILD,
|
||||
};
|
||||
let mut nyx_process = (match nyx_process_type {
|
||||
NyxProcessType::ALONE => NyxProcess::new(
|
||||
|
@ -3,21 +3,45 @@ use typed_builder::TypedBuilder;
|
||||
const DEFAULT_INPUT_BUFFER_SIZE: u32 = 1024 * 1024;
|
||||
const DEFAULT_TIMEOUT_SECS: u8 = 2;
|
||||
const DEFAULT_TIMEOUT_MICRO_SECS: u32 = 0;
|
||||
const DEFAULT_SNAP_MODE: bool = true;
|
||||
|
||||
#[derive(Debug, Clone, Copy, TypedBuilder)]
|
||||
pub struct NyxSettings {
|
||||
/// The CPU core for the Nyx process.
|
||||
///
|
||||
/// Depending on the value of `parent_cpu_id`, the created Nyx process
|
||||
/// will be one of the following types:
|
||||
/// * Standalone: `parent_cpu_id.is_none()`.
|
||||
/// * Parent: `parent_cpu_id.is_some_and(|parent_cpu_id| parent_cpu_id == cpu_id)`.
|
||||
/// * Child: `parent_cpu_id.is_some_and(|parent_cpu_id| parent_cpu_id != cpu_id)`.
|
||||
pub cpu_id: u32,
|
||||
|
||||
/// The CPU core for the Nyx parent process. The parent process
|
||||
/// creates the fuzzing snapshot that can then be used by the child
|
||||
/// processes.
|
||||
///
|
||||
/// Not specifying this will start the Nyx process in standalone mode.
|
||||
pub parent_cpu_id: Option<u32>,
|
||||
|
||||
/// Reload the VM by using the fuzzing snapshot. You probably want
|
||||
/// this to be `true`.
|
||||
#[builder(default = DEFAULT_SNAP_MODE)]
|
||||
pub snap_mode: bool,
|
||||
pub parallel_mode: bool,
|
||||
|
||||
/// The input buffer size (in bytes) used to pass the input to the
|
||||
/// QEMU-Nyx VM.
|
||||
///
|
||||
/// Default is `1MB`.
|
||||
#[builder(default = DEFAULT_INPUT_BUFFER_SIZE)]
|
||||
pub input_buffer_size: u32,
|
||||
|
||||
/// The timeout for a single execution in seconds (until the
|
||||
/// hypervisor restore snapshot call).
|
||||
#[builder(default = DEFAULT_TIMEOUT_SECS)]
|
||||
pub timeout_secs: u8,
|
||||
|
||||
/// Additional timeout in microseconds that gets added to
|
||||
/// `timeout_secs`.
|
||||
#[builder(default = DEFAULT_TIMEOUT_MICRO_SECS)]
|
||||
pub timeout_micro_secs: u32,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user