fix issue more seriously
MODIFY
gcc_plugin/afl-gcc-fast.c
gcc_plugin/afl-gcc-fast.c
@@ -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")) {

MODIFY
llvm_mode/LLVMInsTrim.so.cc
llvm_mode/LLVMInsTrim.so.cc
@@ -480,13 +480,25 @@ struct InsTrim : public ModulePass {
}
- OKF("Instrumented %u locations (%llu, %llu) (%s mode)\n", total_instr,
- total_rs, total_hs,
+ char modeline[100];
+ snprintf(modeline, sizeof(modeline), "%s%s%s%s",
getenv("AFL_HARDEN")
? "hardened"
- : ((getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN"))
- ? "ASAN/MSAN"
- : "non-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,
+ total_rs, total_hs, modeline);
+
return false;
}

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

MODIFY
src/afl-as.c
src/afl-as.c
@@ -478,13 +478,28 @@ static void add_instrumentation(void) {
if (!ins_lines)
WARNF("No instrumentation targets found%s.",
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,
use_64bit ? "64" : "32",
- getenv("AFL_HARDEN") ? "hardened"
- : (sanitizer ? "ASAN/MSAN" : "non-hardened"),
+ modeline,
inst_ratio);
-
+ }
}
}

MODIFY
src/afl-gcc.c
src/afl-gcc.c
@@ -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
cc_params[cc_par_cnt++] = "-lrt";
#endif

MODIFY
test/test.sh
test/test.sh
@@ -43,6 +43,7 @@ unset AFL_DEBUG
unset AFL_HARDEN
unset AFL_USE_ASAN
unset AFL_USE_MSAN
+unset AFL_USE_UBSAN
unset AFL_CC
unset AFL_PRELOAD
unset AFL_GCC_WHITELIST

fix issue #194 more seriously