Skip to content

Commit dc7d561

Browse files
authored
Don't send unstable entries if there's nothing (#1552)
* shutup calibration * Update build_and_test.yml
1 parent aa7993d commit dc7d561

File tree

3 files changed

+33
-18
lines changed

3 files changed

+33
-18
lines changed

.github/workflows/build_and_test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,16 @@ jobs:
219219
if: runner.os == 'Linux'
220220
run: sudo apt purge llvm* clang*
221221
- uses: lyricwulf/abc@v1
222-
with:
223-
# todo: remove afl++-clang when nyx support samcov_pcguard
224-
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
222+
with:
223+
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
225224
# update bash for macos to support `declare -A` command`
226225
macos: llvm@15 libpng nasm coreutils z3 bash wget
226+
- name: Set clang version
227+
if: runner.os == 'Linux'
228+
run: sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-15 100
229+
- name: Set clang++ version
230+
if: runner.os == 'Linux'
231+
run: sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-15 100
227232
- name: pip install
228233
run: python3 -m pip install msgpack jinja2 find_libpython
229234
# Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters.

libafl/src/stages/calibrate.rs

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ use crate::{
2222
observers::{MapObserver, ObserversTuple, UsesObserver},
2323
schedulers::powersched::SchedulerMetadata,
2424
stages::Stage,
25-
state::{HasClientPerfMonitor, HasCorpus, HasMetadata, HasNamedMetadata, UsesState},
25+
state::{
26+
HasClientPerfMonitor, HasCorpus, HasExecutions, HasMetadata, HasNamedMetadata, UsesState,
27+
},
2628
Error,
2729
};
2830

@@ -90,7 +92,7 @@ where
9092
O: MapObserver,
9193
for<'de> <O as MapObserver>::Entry: Serialize + Deserialize<'de> + 'static,
9294
OT: ObserversTuple<E::State>,
93-
E::State: HasCorpus + HasMetadata + HasClientPerfMonitor + HasNamedMetadata,
95+
E::State: HasCorpus + HasMetadata + HasClientPerfMonitor + HasNamedMetadata + HasExecutions,
9496
Z: Evaluator<E, EM, State = E::State>,
9597
{
9698
#[inline]
@@ -220,7 +222,8 @@ where
220222
i += 1;
221223
}
222224

223-
if !unstable_entries.is_empty() {
225+
let unstable_found = !unstable_entries.is_empty();
226+
if unstable_found {
224227
// If we see new stable entries executing this new corpus entries, then merge with the existing one
225228
if state.has_metadata::<UnstableEntriesMetadata>() {
226229
let existing = state
@@ -293,18 +296,25 @@ where
293296
data.set_handicap(handicap);
294297
}
295298

299+
*state.executions_mut() += i;
300+
296301
// Send the stability event to the broker
297-
if let Some(meta) = state.metadata_map().get::<UnstableEntriesMetadata>() {
298-
let unstable_entries = meta.unstable_entries().len();
299-
let map_len = meta.map_len();
300-
mgr.fire(
301-
state,
302-
Event::UpdateUserStats {
303-
name: "stability".to_string(),
304-
value: UserStats::Ratio((map_len - unstable_entries) as u64, map_len as u64),
305-
phantom: PhantomData,
306-
},
307-
)?;
302+
if unstable_found {
303+
if let Some(meta) = state.metadata_map().get::<UnstableEntriesMetadata>() {
304+
let unstable_entries = meta.unstable_entries().len();
305+
let map_len = meta.map_len();
306+
mgr.fire(
307+
state,
308+
Event::UpdateUserStats {
309+
name: "stability".to_string(),
310+
value: UserStats::Ratio(
311+
(map_len - unstable_entries) as u64,
312+
map_len as u64,
313+
),
314+
phantom: PhantomData,
315+
},
316+
)?;
317+
}
308318
}
309319

310320
Ok(())

libafl_frida/src/cmplog_rt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ extern "C" {
1919
pub fn __libafl_targets_cmplog_instructions(k: u64, shape: u8, arg1: u64, arg2: u64);
2020
}
2121

22-
use frida_gum::ModuleMap;
2322
use std::rc::Rc;
2423

24+
use frida_gum::ModuleMap;
2525
#[cfg(target_arch = "aarch64")]
2626
use frida_gum::{
2727
instruction_writer::{Aarch64Register, IndexMode, InstructionWriter},

0 commit comments

Comments
 (0)