From 159e6ea480e7aef75ff505ad248e87ac1ded892c Mon Sep 17 00:00:00 2001 From: Dominik Maier Date: Thu, 5 Jan 2023 14:26:20 +0100 Subject: [PATCH] Fix Launcher for M1, fix frida_libpng harness compilation, fix CI (#987) * Fix harness compilation for frida_libpng * M1: Always use fast cores * always ignore result * seeing if manualy installing libunistring fixes wget * seeing if manualy installing wget fixes it, instead * un-remove comment --- .github/workflows/build_and_test.yml | 2 +- fuzzers/frida_libpng/harness.cc | 2 +- libafl/src/bolts/core_affinity.rs | 33 ++++++++++------------------ 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 80b80a0ef3..5f9df5c180 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -182,7 +182,7 @@ jobs: # todo: remove afl++-clang when nyx support samcov_pcguard linux: llvm llvm-dev clang nasm ninja-build gcc-arm-linux-gnueabi g++-arm-linux-gnueabi libgtk-3-dev afl++-clang pax-utils # update bash for macos to support `declare -A` command` - macos: llvm libpng nasm coreutils z3 bash + macos: llvm libpng nasm coreutils z3 bash wget - name: pip install run: python3 -m pip install msgpack jinja2 # Note that nproc needs to have coreutils installed on macOS, so the order of CI commands matters. diff --git a/fuzzers/frida_libpng/harness.cc b/fuzzers/frida_libpng/harness.cc index b7fae8e3f1..4c3a7b1aa3 100644 --- a/fuzzers/frida_libpng/harness.cc +++ b/fuzzers/frida_libpng/harness.cc @@ -22,7 +22,7 @@ #include #define PNG_INTERNAL -#include "png.h" +#include "libpng-1.6.37/png.h" #define PNG_CLEANUP \ if (png_handler.png_ptr) { \ diff --git a/libafl/src/bolts/core_affinity.rs b/libafl/src/bolts/core_affinity.rs index 2432c85d14..8606608789 100644 --- a/libafl/src/bolts/core_affinity.rs +++ b/libafl/src/bolts/core_affinity.rs @@ -538,10 +538,7 @@ mod apple { THREAD_AFFINITY_POLICY_COUNT, }; #[cfg(target_arch = "aarch64")] - use libc::{ - pthread_set_qos_class_self_np, qos_class_t::QOS_CLASS_BACKGROUND, - qos_class_t::QOS_CLASS_USER_INITIATED, - }; + use libc::{pthread_set_qos_class_self_np, qos_class_t::QOS_CLASS_USER_INITIATED}; use super::CoreId; use crate::Error; @@ -596,26 +593,18 @@ mod apple { } #[cfg(target_arch = "aarch64")] - pub fn set_for_current(core_id: CoreId) -> Result<(), Error> { - unsafe { - // This is the best we can do, unlike on intel architecture - // the system does not allow to pin a process/thread to specific cpu - // but instead choosing at best between the two available groups - // energy consumption's efficient one and the other focusing more on performance. - let mut qos_class = QOS_CLASS_USER_INITIATED; - if core_id.id % 2 != 0 { - qos_class = QOS_CLASS_BACKGROUND; - } - let result = pthread_set_qos_class_self_np(qos_class, 0); + pub fn set_for_current(_core_id: CoreId) -> Result<(), Error> { + // This is the best we can do, unlike on intel architecture + // the system does not allow to pin a process/thread to specific cpu. + // We just tell the system that we want performance. + // + // Furthermore, this seems to fail on background threads, so we ignore errors (result != 0). - if result == 0 { - Ok(()) - } else { - Err(Error::unknown(format!( - "Failed to set_for_current {result:?}" - ))) - } + unsafe { + let _result = pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0); } + + Ok(()) } }