fix issue #194 more seriously

This commit is contained in:
hexcoder-
2020-02-13 21:06:09 +01:00
parent afb23f09cf
commit 24dcc5eb37
6 changed files with 75 additions and 15 deletions

View File

@ -192,6 +192,14 @@ static void edit_params(u32 argc, char** argv) {
} }
if (getenv("AFL_USE_UBSAN")) {
cc_params[cc_par_cnt++] = "-fsanitize=undefined";
cc_params[cc_par_cnt++] = "-fsanitize-undefined-trap-on-error";
cc_params[cc_par_cnt++] = "-fno-sanitize-recover=all";
}
} }
if (!getenv("AFL_DONT_OPTIMIZE")) { if (!getenv("AFL_DONT_OPTIMIZE")) {

View File

@ -480,13 +480,25 @@ struct InsTrim : public ModulePass {
} }
char modeline[100];
snprintf(modeline, sizeof(modeline), "%s%s%s%s",
getenv("AFL_HARDEN")
? "hardened"
: "non-hardened",
getenv("AFL_USE_ASAN")
? ", ASAN"
: "",
getenv("AFL_USE_MSAN")
? ", MSAN"
: "",
getenv("AFL_USE_UBSAN")
? ", UBSAN"
: ""
);
OKF("Instrumented %u locations (%llu, %llu) (%s mode)\n", total_instr, OKF("Instrumented %u locations (%llu, %llu) (%s mode)\n", total_instr,
total_rs, total_hs, total_rs, total_hs, modeline);
getenv("AFL_HARDEN")
? "hardened"
: ((getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN"))
? "ASAN/MSAN"
: "non-hardened"));
return false; return false;
} }

View File

@ -467,14 +467,26 @@ bool AFLCoverage::runOnModule(Module &M) {
if (!inst_blocks) if (!inst_blocks)
WARNF("No instrumentation targets found."); WARNF("No instrumentation targets found.");
else else {
OKF("Instrumented %u locations (%s mode, ratio %u%%).", inst_blocks, char modeline[100];
snprintf(modeline, sizeof(modeline), "%s%s%s%s",
getenv("AFL_HARDEN") getenv("AFL_HARDEN")
? "hardened" ? "hardened"
: ((getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN")) : "non-hardened",
? "ASAN/MSAN" getenv("AFL_USE_ASAN")
: "non-hardened"), ? ", ASAN"
: "",
getenv("AFL_USE_MSAN")
? ", MSAN"
: "",
getenv("AFL_USE_UBSAN")
? ", UBSAN"
: ""
);
OKF("Instrumented %u locations (%s mode, ratio %u%%).", inst_blocks,
modeline,
inst_ratio); inst_ratio);
}
} }

View File

@ -478,13 +478,28 @@ static void add_instrumentation(void) {
if (!ins_lines) if (!ins_lines)
WARNF("No instrumentation targets found%s.", WARNF("No instrumentation targets found%s.",
pass_thru ? " (pass-thru mode)" : ""); pass_thru ? " (pass-thru mode)" : "");
else else {
char modeline[100];
snprintf(modeline, sizeof(modeline), "%s%s%s%s",
getenv("AFL_HARDEN")
? "hardened"
: "non-hardened",
getenv("AFL_USE_ASAN")
? ", ASAN"
: "",
getenv("AFL_USE_MSAN")
? ", MSAN"
: "",
getenv("AFL_USE_UBSAN")
? ", UBSAN"
: ""
);
OKF("Instrumented %u locations (%s-bit, %s mode, ratio %u%%).", ins_lines, OKF("Instrumented %u locations (%s-bit, %s mode, ratio %u%%).", ins_lines,
use_64bit ? "64" : "32", use_64bit ? "64" : "32",
getenv("AFL_HARDEN") ? "hardened" modeline,
: (sanitizer ? "ASAN/MSAN" : "non-hardened"),
inst_ratio); inst_ratio);
}
} }
} }

View File

@ -282,6 +282,18 @@ static void edit_params(u32 argc, char** argv) {
} }
if (!asan_set) {
if (getenv("AFL_USE_UBSAN")) {
cc_params[cc_par_cnt++] = "-fsanitize=undefined";
cc_params[cc_par_cnt++] = "-fsanitize-undefined-trap-on-error";
cc_params[cc_par_cnt++] = "-fno-sanitize-recover=all";
}
}
#ifdef USEMMAP #ifdef USEMMAP
cc_params[cc_par_cnt++] = "-lrt"; cc_params[cc_par_cnt++] = "-lrt";
#endif #endif

View File

@ -43,6 +43,7 @@ unset AFL_DEBUG
unset AFL_HARDEN unset AFL_HARDEN
unset AFL_USE_ASAN unset AFL_USE_ASAN
unset AFL_USE_MSAN unset AFL_USE_MSAN
unset AFL_USE_UBSAN
unset AFL_CC unset AFL_CC
unset AFL_PRELOAD unset AFL_PRELOAD
unset AFL_GCC_WHITELIST unset AFL_GCC_WHITELIST