Don't send unstable entries if there's nothing (#1552)

* shutup calibration

* Update build_and_test.yml
This commit is contained in:
Dongjia "toka" Zhang 2023-09-24 17:27:12 +02:00 committed by GitHub
parent aa7993de10
commit dc7d561621
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 18 deletions

View File

@ -220,10 +220,15 @@ jobs:
run: sudo apt purge llvm* clang* run: sudo apt purge llvm* clang*
- uses: lyricwulf/abc@v1 - uses: lyricwulf/abc@v1
with: with:
# todo: remove afl++-clang when nyx support samcov_pcguard linux: llvm-15 llvm-15-dev clang-15 nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev pax-utils libz3-dev
linux: llvm-15 llvm-15-dev clang-15 nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi gcc-aarch64-linux-gnu g++-aarch64-linux-gnu gcc-mipsel-linux-gnu g++-mipsel-linux-gnu gcc-powerpc-linux-gnu g++-powerpc-linux-gnu libc6-dev-i386-cross libc6-dev libc6-dev-i386 lib32gcc-11-dev lib32stdc++-11-dev libgtk-3-dev afl++-clang pax-utils libz3-dev
# update bash for macos to support `declare -A` command` # update bash for macos to support `declare -A` command`
macos: llvm@15 libpng nasm coreutils z3 bash wget macos: llvm@15 libpng nasm coreutils z3 bash wget
- name: Set clang version
if: runner.os == 'Linux'
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
- name: Set clang++ version
if: runner.os == 'Linux'
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
- name: pip install - name: pip install
run: python3 -m pip install msgpack jinja2 find_libpython run: python3 -m pip install msgpack jinja2 find_libpython
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.

View File

@ -22,7 +22,9 @@ use crate::{
observers::{MapObserver, ObserversTuple, UsesObserver}, observers::{MapObserver, ObserversTuple, UsesObserver},
schedulers::powersched::SchedulerMetadata, schedulers::powersched::SchedulerMetadata,
stages::Stage, stages::Stage,
state::{HasClientPerfMonitor, HasCorpus, HasMetadata, HasNamedMetadata, UsesState}, state::{
HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata, HasNamedMetadata, UsesState,
},
Error, Error,
}; };
@ -90,7 +92,7 @@ where
O: MapObserver, O: MapObserver,
for<'de> <O as MapObserver>::Entry: Serialize + Deserialize<'de> + 'static, for<'de> <O as MapObserver>::Entry: Serialize + Deserialize<'de> + 'static,
OT: ObserversTuple<E::State>, OT: ObserversTuple<E::State>,
E::State: HasCorpus + HasMetadata + HasClientPerfMonitor + HasNamedMetadata, E::State: HasCorpus + HasMetadata + HasClientPerfMonitor + HasNamedMetadata + HasExecutions,
Z: Evaluator<E, EM, State = E::State>, Z: Evaluator<E, EM, State = E::State>,
{ {
#[inline] #[inline]
@ -220,7 +222,8 @@ where
i += 1; i += 1;
} }
if !unstable_entries.is_empty() { let unstable_found = !unstable_entries.is_empty();
if unstable_found {
// If we see new stable entries executing this new corpus entries, then merge with the existing one // If we see new stable entries executing this new corpus entries, then merge with the existing one
if state.has_metadata::<UnstableEntriesMetadata>() { if state.has_metadata::<UnstableEntriesMetadata>() {
let existing = state let existing = state
@ -293,7 +296,10 @@ where
data.set_handicap(handicap); data.set_handicap(handicap);
} }
*state.executions_mut() += i;
// Send the stability event to the broker // Send the stability event to the broker
if unstable_found {
if let Some(meta) = state.metadata_map().get::<UnstableEntriesMetadata>() { if let Some(meta) = state.metadata_map().get::<UnstableEntriesMetadata>() {
let unstable_entries = meta.unstable_entries().len(); let unstable_entries = meta.unstable_entries().len();
let map_len = meta.map_len(); let map_len = meta.map_len();
@ -301,11 +307,15 @@ where
state, state,
Event::UpdateUserStats { Event::UpdateUserStats {
name: "stability".to_string(), name: "stability".to_string(),
value: UserStats::Ratio((map_len - unstable_entries) as u64, map_len as u64), value: UserStats::Ratio(
(map_len - unstable_entries) as u64,
map_len as u64,
),
phantom: PhantomData, phantom: PhantomData,
}, },
)?; )?;
} }
}
Ok(()) Ok(())
} }

View File

@ -19,9 +19,9 @@ extern "C" {
pub fn __libafl_targets_cmplog_instructions(k: u64, shape: u8, arg1: u64, arg2: u64); pub fn __libafl_targets_cmplog_instructions(k: u64, shape: u8, arg1: u64, arg2: u64);
} }
use frida_gum::ModuleMap;
use std::rc::Rc; use std::rc::Rc;
use frida_gum::ModuleMap;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
use frida_gum::{ use frida_gum::{
instruction_writer::{Aarch64Register, IndexMode, InstructionWriter}, instruction_writer::{Aarch64Register, IndexMode, InstructionWriter},