Merge pull request #164 from AFLplusplus/cmplog_instrumentation

frida: add `cmplog-cores` option
This commit is contained in:
s1341 2021-06-09 17:56:55 +03:00 committed by GitHub
commit 3d84a8d081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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