add cmplog_cores command line argument support

This commit is contained in:
Omree 2021-06-09 16:27:22 +03:00
parent b8e4f4c6fa
commit ed26319a21

View File

@ -17,7 +17,7 @@ pub mod cmplog_rt;
/// The `LibAFL` firda helper
pub mod helper;
// for parsing asan cores
// for parsing asan and cmplog cores
use libafl::bolts::os::parse_core_bind_arg;
// for getting current core_id
use core_affinity::get_core_ids;
@ -47,6 +47,7 @@ impl FridaOptions {
pub fn parse_env_options() -> Self {
let mut options = Self::default();
let mut asan_cores = None;
let mut cmplog_cores = None;
if let Ok(env_options) = std::env::var("LIBAFL_FRIDA_OPTIONS") {
for option in env_options.trim().split(':') {
@ -108,10 +109,21 @@ impl FridaOptions {
}
"cmplog" => {
options.enable_cmplog = value.parse().unwrap();
#[cfg(not(target_arch = "aarch64"))]
if options.enable_cmplog {
panic!(
"cmplog is not currently supported on targets other than aarch64"
);
}
if !cfg!(feature = "cmplog") && options.enable_cmplog {
panic!("cmplog feature is disabled!")
}
}
"cmplog_cores" => {
cmplog_cores = parse_core_bind_arg(value);
}
_ => {
panic!("unknown FRIDA option: '{}'", option);
}
@ -124,14 +136,25 @@ impl FridaOptions {
assert_eq!(
core_ids.len(),
1,
"Client should only be enabled on one core"
"[asan_cores] Client should only be enabled on one core"
);
let core_id = core_ids[0].id;
options.enable_asan = asan_cores.contains(&core_id);
}
}
if options.enable_cmplog {
if let Some(cmplog_cores) = cmplog_cores {
let core_ids = get_core_ids().unwrap();
assert_eq!(
core_ids.len(),
1,
"[cmplog_cores] Client should only be enabled on one core"
);
let core_id = core_ids[0].id;
options.enable_cmplog = cmplog_cores.contains(&core_id);
}
}
}
options
}