From b4e6115d4f05b8b6af61e9bf55d07552f7d2c405 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Mon, 29 Mar 2021 15:57:27 +0200 Subject: [PATCH] fixes for pcguard and value profile --- Cargo.toml | 6 +----- libafl_targets/src/pcguard.rs | 8 ++++---- libafl_targets/src/value_profile.rs | 6 +++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index cc9355c666..6710352a0e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,15 +10,11 @@ members = [ "libafl_derive", "libafl_cc", "libafl_targets", - - #example fuzzers - "fuzzers/libfuzzer_libmozjpeg", - "fuzzers/libfuzzer_libpng_cmpalloc", - "fuzzers/libfuzzer_windows", ] exclude = [ "fuzzers/libfuzzer_libpng", "fuzzers/libfuzzer_stb_image", + "fuzzers/libfuzzer_libmozjpeg", "fuzzers/frida_libpng", "fuzzers/qemu_user", ] diff --git a/libafl_targets/src/pcguard.rs b/libafl_targets/src/pcguard.rs index a90b3a659d..b7fff8bd5e 100644 --- a/libafl_targets/src/pcguard.rs +++ b/libafl_targets/src/pcguard.rs @@ -4,10 +4,10 @@ compile_error!( ); // TODO compile time flag -pub const MAP_SIZE: usize = 65536; +pub const EDGES_MAP_SIZE: usize = 65536; -pub static mut EDGES_MAP: [u8; MAP_SIZE] = [0; MAP_SIZE]; -//pub static mut CMP_MAP: [u8; MAP_SIZE] = [0; MAP_SIZE]; +pub static mut EDGES_MAP: [u8; EDGES_MAP_SIZE] = [0; EDGES_MAP_SIZE]; +//pub static mut CMP_MAP: [u8; EDGES_MAP_SIZE] = [0; EDGES_MAP_SIZE]; pub static mut MAX_EDGES_NUM: usize = 0; #[no_mangle] @@ -32,7 +32,7 @@ pub unsafe extern "C" fn __sanitizer_cov_trace_pc_guard_init(mut start: *mut u32 while start < stop { MAX_EDGES_NUM += 1; - *start = (MAX_EDGES_NUM & (MAP_SIZE - 1)) as u32; + *start = (MAX_EDGES_NUM & (EDGES_MAP_SIZE - 1)) as u32; start = start.offset(1); } } diff --git a/libafl_targets/src/value_profile.rs b/libafl_targets/src/value_profile.rs index d5aabd8872..b5f0d2981c 100644 --- a/libafl_targets/src/value_profile.rs +++ b/libafl_targets/src/value_profile.rs @@ -1,8 +1,8 @@ // TODO compile time flag -pub const MAP_SIZE: usize = 65536; +pub const CMP_MAP_SIZE: usize = 65536; #[no_mangle] -pub static mut libafl_cmp_map: [u8; MAP_SIZE] = [0; MAP_SIZE]; +pub static mut libafl_cmp_map: [u8; CMP_MAP_SIZE] = [0; CMP_MAP_SIZE]; pub use libafl_cmp_map as CMP_MAP; @@ -16,7 +16,7 @@ extern { pub unsafe extern "C" fn __sanitizer_cov_trace_cmp1(arg1: u8, arg2: u8) { let mut pos = return_address(); pos = (pos >> 4) ^ (pos << 8); - pos &= MAP_SIZE - 1; + pos &= CMP_MAP_SIZE - 1; *CMP_MAP.get_unchecked_mut(pos) = core::cmp::max(*CMP_MAP.get_unchecked(pos), (!(arg1 ^ arg2)).count_ones() as u8); } */