aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2023-02-21 01:11:00 +0100
committerGitHub <noreply@github.com>2023-02-21 01:11:00 +0100
commitc33f8751e3f1051c4fe6859d16a0494282c8e34b (patch)
treecffa425593885192ec6d24416ab5b436ca0f5938 /src
parent1faf6f67313e726c645ac3b9ecd2d8b5e65f605a (diff)
parent6f4b5ae0832774389b12c5a8cd3fb95821b438e5 (diff)
downloadafl++-c33f8751e3f1051c4fe6859d16a0494282c8e34b.tar.gz
Merge pull request #1651 from AFLplusplus/dev
Dev
Diffstat (limited to 'src')
-rw-r--r--src/afl-forkserver.c2
-rw-r--r--src/afl-fuzz-cmplog.c2
-rw-r--r--src/afl-fuzz-mutators.c12
-rw-r--r--src/afl-fuzz-one.c6
-rw-r--r--src/afl-fuzz-queue.c6
-rw-r--r--src/afl-fuzz-redqueen.c2
-rw-r--r--src/afl-fuzz.c17
-rw-r--r--src/afl-gotcpu.c12
8 files changed, 45 insertions, 14 deletions
diff --git a/src/afl-forkserver.c b/src/afl-forkserver.c
index 89d01460..5aa4c2ff 100644
--- a/src/afl-forkserver.c
+++ b/src/afl-forkserver.c
@@ -1370,7 +1370,7 @@ afl_fsrv_run_target(afl_forkserver_t *fsrv, u32 timeout,
case Crash:
case Asan:
return FSRV_RUN_CRASH;
- case Timout:
+ case Timeout:
return FSRV_RUN_TMOUT;
case InvalidWriteToPayload:
/* ??? */
diff --git a/src/afl-fuzz-cmplog.c b/src/afl-fuzz-cmplog.c
index 8967d4bc..2bf26d19 100644
--- a/src/afl-fuzz-cmplog.c
+++ b/src/afl-fuzz-cmplog.c
@@ -41,7 +41,7 @@ void cmplog_exec_child(afl_forkserver_t *fsrv, char **argv) {
}
- execv(argv[0], argv);
+ execv(fsrv->target_path, argv);
}
diff --git a/src/afl-fuzz-mutators.c b/src/afl-fuzz-mutators.c
index ce43064a..9ea46e7a 100644
--- a/src/afl-fuzz-mutators.c
+++ b/src/afl-fuzz-mutators.c
@@ -312,12 +312,18 @@ struct custom_mutator *load_custom_mutator(afl_state_t *afl, const char *fn) {
if (notrim) {
+ if (mutator->afl_custom_init_trim || mutator->afl_custom_trim ||
+ mutator->afl_custom_post_trim) {
+
+ WARNF(
+ "Custom mutator does not implement all three trim APIs, standard "
+ "trimming will be used.");
+
+ }
+
mutator->afl_custom_init_trim = NULL;
mutator->afl_custom_trim = NULL;
mutator->afl_custom_post_trim = NULL;
- ACTF(
- "Custom mutator does not implement all three trim APIs, standard "
- "trimming will be used.");
}
diff --git a/src/afl-fuzz-one.c b/src/afl-fuzz-one.c
index e97db273..be526dbd 100644
--- a/src/afl-fuzz-one.c
+++ b/src/afl-fuzz-one.c
@@ -5691,6 +5691,7 @@ pacemaker_fuzzing:
} /* block */
+ ++afl->queue_cur->fuzz_level;
return ret_val;
}
@@ -5804,7 +5805,7 @@ void pso_updating(afl_state_t *afl) {
depending on the configuration. */
u8 fuzz_one(afl_state_t *afl) {
- int key_val_lv_1 = 0, key_val_lv_2 = 0;
+ int key_val_lv_1 = -1, key_val_lv_2 = -1;
#ifdef _AFL_DOCUMENT_MUTATIONS
@@ -5851,6 +5852,9 @@ u8 fuzz_one(afl_state_t *afl) {
}
+ if (unlikely(key_val_lv_1 == -1)) { key_val_lv_1 = 0; }
+ if (likely(key_val_lv_2 == -1)) { key_val_lv_2 = 0; }
+
return (key_val_lv_1 | key_val_lv_2);
}
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index 3c8a3e46..65446799 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -1028,10 +1028,16 @@ u32 calculate_score(afl_state_t *afl, struct queue_entry *q) {
break;
case LIN:
+ // Don't modify perf_score for unfuzzed seeds
+ if (!q->fuzz_level) break;
+
factor = q->fuzz_level / (afl->n_fuzz[q->n_fuzz_entry] + 1);
break;
case QUAD:
+ // Don't modify perf_score for unfuzzed seeds
+ if (!q->fuzz_level) break;
+
factor =
q->fuzz_level * q->fuzz_level / (afl->n_fuzz[q->n_fuzz_entry] + 1);
break;
diff --git a/src/afl-fuzz-redqueen.c b/src/afl-fuzz-redqueen.c
index 8da1df13..290be881 100644
--- a/src/afl-fuzz-redqueen.c
+++ b/src/afl-fuzz-redqueen.c
@@ -1624,6 +1624,8 @@ static void try_to_add_to_dictN(afl_state_t *afl, u128 v, u8 size) {
}
+ if (cons_0 > 1 || cons_ff > 1) { return; }
+
}
maybe_add_auto(afl, (u8 *)&v + off, size);
diff --git a/src/afl-fuzz.c b/src/afl-fuzz.c
index 4de2baf6..ea467401 100644
--- a/src/afl-fuzz.c
+++ b/src/afl-fuzz.c
@@ -1298,6 +1298,12 @@ int main(int argc, char **argv_orig, char **envp) {
}
+ if (afl->is_main_node == 1 && afl->schedule != FAST && afl->schedule != EXPLORE) {
+
+ FATAL("-M is compatible only with fast and explore -p power schedules");
+
+ }
+
if (optind == argc || !afl->in_dir || !afl->out_dir || show_help) {
usage(argv[0], show_help);
@@ -1346,12 +1352,11 @@ int main(int argc, char **argv_orig, char **envp) {
}
#endif
- if (afl->sync_id && afl->is_main_node &&
- afl->afl_env.afl_custom_mutator_only) {
+ if (!afl->skip_deterministic && afl->afl_env.afl_custom_mutator_only) {
- WARNF(
- "Using -M main node with the AFL_CUSTOM_MUTATOR_ONLY mutator options "
- "will result in no deterministic mutations being done!");
+ FATAL(
+ "Using -D determinstic fuzzing is incompatible with "
+ "AFL_CUSTOM_MUTATOR_ONLY!");
}
@@ -2106,6 +2111,7 @@ int main(int argc, char **argv_orig, char **envp) {
afl->cmplog_fsrv.qemu_mode = afl->fsrv.qemu_mode;
afl->cmplog_fsrv.frida_mode = afl->fsrv.frida_mode;
afl->cmplog_fsrv.cmplog_binary = afl->cmplog_binary;
+ afl->cmplog_fsrv.target_path = afl->fsrv.target_path;
afl->cmplog_fsrv.init_child_func = cmplog_exec_child;
if ((map_size <= DEFAULT_SHMEM_SIZE ||
@@ -2574,6 +2580,7 @@ int main(int argc, char **argv_orig, char **envp) {
skipped_fuzz = fuzz_one(afl);
#ifdef INTROSPECTION
++afl->queue_cur->stats_selected;
+
if (unlikely(skipped_fuzz)) {
++afl->queue_cur->stats_skipped;
diff --git a/src/afl-gotcpu.c b/src/afl-gotcpu.c
index c5b8a27a..8988fd54 100644
--- a/src/afl-gotcpu.c
+++ b/src/afl-gotcpu.c
@@ -92,7 +92,7 @@ static u32 measure_preemption(u32 target_ms) {
volatile u32 v1, v2 = 0;
u64 st_t, en_t, st_c, en_c, real_delta, slice_delta;
- s32 loop_repeats = 0;
+ //s32 loop_repeats = 0;
st_t = get_cur_time_us();
st_c = get_cpu_usage_us();
@@ -113,7 +113,7 @@ repeat_loop:
if (en_t - st_t < target_ms * 1000) {
- loop_repeats++;
+ //loop_repeats++;
goto repeat_loop;
}
@@ -214,7 +214,13 @@ int main(int argc, char **argv) {
#if defined(__linux__)
if (sched_setaffinity(0, sizeof(c), &c)) {
- PFATAL("sched_setaffinity failed for cpu %d", i);
+ const char *error_code = "Unkown error code";
+ if (errno == EFAULT) error_code = "EFAULT";
+ if (errno == EINVAL) error_code = "EINVAL";
+ if (errno == EPERM) error_code = "EPERM";
+ if (errno == ESRCH) error_code = "ESRCH";
+
+ PFATAL("sched_setaffinity failed for cpu %d, error: %s", i, error_code);
}