about summary refs log tree commit diff
path: root/src/afl-cc.c
diff options
context:
space:
mode:
authorJoshua Rogers <jrogers@opera.com>2021-12-30 02:54:40 +0100
committerJoshua Rogers <jrogers@opera.com>2021-12-30 02:54:40 +0100
commit09c4d9ed7574c78bc89edda230e9396d1e79f795 (patch)
tree979a8b00b4fd082c5b4d163ae7a0886b30500baf /src/afl-cc.c
parent02082bcd2e0928a436593ef67ba84af1c87287e4 (diff)
downloadafl++-09c4d9ed7574c78bc89edda230e9396d1e79f795.tar.gz
Fix LeakSanitizer Usage.
Previously, __lsan_do_leak_check() was run when using __AFL_LEAK_CHECK,
however this was the incorrect function to use. According to the
documentation: "Subsequent calls to this function will have no effect
and end-of-process leak check will not run".
This meant that if the memory did not leak on the first usage of
__AFL_LEAK_CHECK, subsquent calls to this macro would never do anything.

Likewise, it is not possible to use an LSAN suppression list with
symbolize=0, so instead __lsan_disable and __lsan_enable are used to
'ignore' certain memory allocations where needed.
Diffstat (limited to 'src/afl-cc.c')
-rw-r--r--src/afl-cc.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/afl-cc.c b/src/afl-cc.c
index 6771a5f4..d7c71e7d 100644
--- a/src/afl-cc.c
+++ b/src/afl-cc.c
@@ -876,7 +876,10 @@ static void edit_params(u32 argc, char **argv, char **envp) {
 
     cc_params[cc_par_cnt++] = "-fsanitize=leak";
     cc_params[cc_par_cnt++] = "-includesanitizer/lsan_interface.h";
-    cc_params[cc_par_cnt++] = "-D__AFL_LEAK_CHECK()=__lsan_do_leak_check()";
+    cc_params[cc_par_cnt++] = "-D__AFL_LEAK_CHECK()={if(__lsan_do_recoverable_leak_check() > 0) _exit(23); }";
+    cc_params[cc_par_cnt++] = "-D__AFL_LSAN_OFF()=__lsan_disable();";
+    cc_params[cc_par_cnt++] = "-D__AFL_LSAN_ON()=__lsan_disable();";
+
 
   }