aboutsummaryrefslogtreecommitdiff
path: root/frida_mode/src/instrument
diff options
context:
space:
mode:
authorWorksButNotTested <62701594+WorksButNotTested@users.noreply.github.com>2022-07-21 18:48:21 +0100
committerGitHub <noreply@github.com>2022-07-21 19:48:21 +0200
commit9657b700b1df90797b17e1d4677d56ee97fe00bc (patch)
treeab1e399aaae96d7dbbb92863b2c136a42e5004df /frida_mode/src/instrument
parent6c26434a631dce949a39268f9f31e0936cf3dd83 (diff)
downloadafl++-9657b700b1df90797b17e1d4677d56ee97fe00bc.tar.gz
Fix some OSX incompatibilities on AARCH64 (#1479)
Co-authored-by: Your Name <you@example.com>
Diffstat (limited to 'frida_mode/src/instrument')
-rw-r--r--frida_mode/src/instrument/instrument.c3
-rw-r--r--frida_mode/src/instrument/instrument_arm64.c3
-rw-r--r--frida_mode/src/instrument/instrument_x64.c9
-rw-r--r--frida_mode/src/instrument/instrument_x86.c3
4 files changed, 10 insertions, 8 deletions
diff --git a/frida_mode/src/instrument/instrument.c b/frida_mode/src/instrument/instrument.c
index 9ee7db2d..a9568390 100644
--- a/frida_mode/src/instrument/instrument.c
+++ b/frida_mode/src/instrument/instrument.c
@@ -20,6 +20,8 @@
#include "stats.h"
#include "util.h"
+#define FRIDA_DEFAULT_MAP_SIZE (64UL << 10)
+
gboolean instrument_tracing = false;
gboolean instrument_optimize = false;
gboolean instrument_unique = false;
@@ -289,6 +291,7 @@ void instrument_config(void) {
}
void instrument_init(void) {
+ if (__afl_map_size == MAP_SIZE) __afl_map_size = FRIDA_DEFAULT_MAP_SIZE;
if (!instrument_is_coverage_optimize_supported()) instrument_optimize = false;
diff --git a/frida_mode/src/instrument/instrument_arm64.c b/frida_mode/src/instrument/instrument_arm64.c
index afc20f42..3c37ea5f 100644
--- a/frida_mode/src/instrument/instrument_arm64.c
+++ b/frida_mode/src/instrument/instrument_arm64.c
@@ -272,9 +272,10 @@ void instrument_coverage_optimize(const cs_insn *instr,
GumAddressSpec spec = {.near_address = cw->code,
.max_distance = 1ULL << 30};
+ guint page_size = gum_query_page_size();
instrument_previous_pc_addr = gum_memory_allocate_near(
- &spec, sizeof(guint64), 0x1000, GUM_PAGE_READ | GUM_PAGE_WRITE);
+ &spec, sizeof(guint64), page_size, GUM_PAGE_READ | GUM_PAGE_WRITE);
*instrument_previous_pc_addr = instrument_hash_zero;
FVERBOSE("instrument_previous_pc_addr: %p", instrument_previous_pc_addr);
FVERBOSE("code_addr: %p", cw->code);
diff --git a/frida_mode/src/instrument/instrument_x64.c b/frida_mode/src/instrument/instrument_x64.c
index bfafe067..687b2e40 100644
--- a/frida_mode/src/instrument/instrument_x64.c
+++ b/frida_mode/src/instrument/instrument_x64.c
@@ -333,19 +333,17 @@ static void instrument_coverage_write(GumAddress address,
}
-void instrument_coverage_optimize(const cs_insn *instr,
+void instrument_coverage_optimize(const cs_insn * instr,
GumStalkerOutput *output) {
-
GumX86Writer *cw = output->writer.x86;
- /* guint64 area_offset =
- * instrument_get_offset_hash(GUM_ADDRESS(instr->address)); */
if (instrument_previous_pc_addr == NULL) {
GumAddressSpec spec = {.near_address = cw->code,
.max_distance = 1ULL << 30};
+ guint page_size = gum_query_page_size();
instrument_previous_pc_addr = gum_memory_allocate_near(
- &spec, sizeof(guint64), 0x1000, GUM_PAGE_READ | GUM_PAGE_WRITE);
+ &spec, sizeof(guint64), page_size, GUM_PAGE_READ | GUM_PAGE_WRITE);
*instrument_previous_pc_addr = instrument_hash_zero;
FVERBOSE("instrument_previous_pc_addr: %p", instrument_previous_pc_addr);
FVERBOSE("code_addr: %p", cw->code);
@@ -361,7 +359,6 @@ void instrument_coverage_optimize(const cs_insn *instr,
}
instrument_coverage_write(GUM_ADDRESS(instr->address), output);
-
}
void instrument_coverage_optimize_insn(const cs_insn *instr,
diff --git a/frida_mode/src/instrument/instrument_x86.c b/frida_mode/src/instrument/instrument_x86.c
index 048daf32..8798cfcf 100644
--- a/frida_mode/src/instrument/instrument_x86.c
+++ b/frida_mode/src/instrument/instrument_x86.c
@@ -162,9 +162,10 @@ void instrument_coverage_optimize(const cs_insn *instr,
GumAddressSpec spec = {.near_address = cw->code,
.max_distance = 1ULL << 30};
+ guint page_size = gum_query_page_size();
instrument_previous_pc_addr = gum_memory_allocate_near(
- &spec, sizeof(guint64), 0x1000, GUM_PAGE_READ | GUM_PAGE_WRITE);
+ &spec, sizeof(guint64), page_size, GUM_PAGE_READ | GUM_PAGE_WRITE);
*instrument_previous_pc_addr = instrument_hash_zero;
FVERBOSE("instrument_previous_pc_addr: %p", instrument_previous_pc_addr);
FVERBOSE("code_addr: %p", cw->code);