Skip to content

Commit

Permalink
Fix Launcher for M1, fix frida_libpng harness compilation, fix CI (#987)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
domenukk committed Jan 5, 2023
1 parent 266677b commit 159e6ea
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_test.yml
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion fuzzers/frida_libpng/harness.cc
Expand Up @@ -22,7 +22,7 @@
#include <vector>

#define PNG_INTERNAL
#include "png.h"
#include "libpng-1.6.37/png.h"

#define PNG_CLEANUP \
if (png_handler.png_ptr) { \
Expand Down
33 changes: 11 additions & 22 deletions libafl/src/bolts/core_affinity.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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(())
}
}

Expand Down

0 comments on commit 159e6ea

Please sign in to comment.