diff --git a/libafl_frida/src/lib.rs b/libafl_frida/src/lib.rs index 31063c899b..7ae5ba6962 100644 --- a/libafl_frida/src/lib.rs +++ b/libafl_frida/src/lib.rs @@ -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,20 @@ 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 +135,25 @@ impl FridaOptions { assert_eq!( core_ids.len(), 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; 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 }