diff options
author | hexcoder- <heiko@hexco.de> | 2020-02-13 21:06:09 +0100 |
---|---|---|
committer | hexcoder- <heiko@hexco.de> | 2020-02-13 21:06:09 +0100 |
commit | 24dcc5eb37dcb3c657ceef5fa33b48b1237342f5 (patch) | |
tree | 859f35aa7dca7c516d88873f9fec162d7162ea16 | |
parent | afb23f09cf921d54ef9d11d5fa2a219f824ee025 (diff) | |
download | afl++-24dcc5eb37dcb3c657ceef5fa33b48b1237342f5.tar.gz |
fix issue #194 more seriously
-rw-r--r-- | gcc_plugin/afl-gcc-fast.c | 8 | ||||
-rw-r--r-- | llvm_mode/LLVMInsTrim.so.cc | 24 | ||||
-rw-r--r-- | llvm_mode/afl-llvm-pass.so.cc | 22 | ||||
-rw-r--r-- | src/afl-as.c | 23 | ||||
-rw-r--r-- | src/afl-gcc.c | 12 | ||||
-rwxr-xr-x | test/test.sh | 1 |
6 files changed, 75 insertions, 15 deletions
diff --git a/gcc_plugin/afl-gcc-fast.c b/gcc_plugin/afl-gcc-fast.c index 3117ccf0..2eef8798 100644 --- a/gcc_plugin/afl-gcc-fast.c +++ b/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")) { diff --git a/llvm_mode/LLVMInsTrim.so.cc b/llvm_mode/LLVMInsTrim.so.cc index 5b7b79e1..9f5bf2a7 100644 --- a/llvm_mode/LLVMInsTrim.so.cc +++ b/llvm_mode/LLVMInsTrim.so.cc @@ -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, - total_rs, total_hs, - getenv("AFL_HARDEN") - ? "hardened" - : ((getenv("AFL_USE_ASAN") || getenv("AFL_USE_MSAN")) - ? "ASAN/MSAN" - : "non-hardened")); + total_rs, total_hs, modeline); + return false; } diff --git a/llvm_mode/afl-llvm-pass.so.cc b/llvm_mode/afl-llvm-pass.so.cc index 2cd23adf..77d63ce4 100644 --- a/llvm_mode/afl-llvm-pass.so.cc +++ b/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); + } } diff --git a/src/afl-as.c b/src/afl-as.c index 5fa83569..12192838 100644 --- a/src/afl-as.c +++ b/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); - + } } } diff --git a/src/afl-gcc.c b/src/afl-gcc.c index e46fe5cd..5ead32fb 100644 --- a/src/afl-gcc.c +++ b/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 diff --git a/test/test.sh b/test/test.sh index c78297f6..1a3ae4ea 100755 --- a/test/test.sh +++ b/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 |