diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-05-18 17:54:03 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-05-20 19:40:20 +0200 |
| commit | 8285069f89c9942f65ce760a8f0a5a12254bfeeb (patch) | |
| tree | df5cc7298195f227005e11489fdad8c25458847e /executor/common.h | |
| parent | 7b3084af2ea815515ea35f9904ee38b5991e58d5 (diff) | |
executor: implement support for leak checking
Leak checking support was half done and did not really work.
This is heavy-lifting to make it work.
1. Move leak/fault setup into executor.
pkg/host was a wrong place for them because we need then in C repros too.
The pkg/host periodic callback functionality did not work too,
we need it in executor so that we can reuse it in C repros too.
Remove setup/callback functions in pkg/host entirely.
2. Do leak setup/checking in C repros.
The way leak checking is invoked is slightly different from fuzzer,
but much better then no support at all.
At least the checking code is shared.
3. Add Leak option to pkg/csource and -leak flag to syz-prog2c.
4. Don't enalbe leak checking in fuzzer while we are triaging initial corpus.
It's toooo slow.
5. Fix pkg/repro to do something more sane for leak bugs.
Few other minor fixes here and there.
Diffstat (limited to 'executor/common.h')
| -rw-r--r-- | executor/common.h | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/executor/common.h b/executor/common.h index 27a7380f7..db2e1204e 100644 --- a/executor/common.h +++ b/executor/common.h @@ -145,7 +145,8 @@ static void sleep_ms(uint64 ms) } #endif -#if SYZ_EXECUTOR || SYZ_THREADED || SYZ_REPEAT && SYZ_EXECUTOR_USES_FORK_SERVER +#if SYZ_EXECUTOR || SYZ_THREADED || SYZ_REPEAT && SYZ_EXECUTOR_USES_FORK_SERVER || \ + SYZ_ENABLE_LEAK #include <time.h> static uint64 current_time_ms(void) @@ -218,7 +219,7 @@ static void remove_dir(const char* dir) #endif #if !GOOS_linux -#if SYZ_EXECUTOR || SYZ_FAULT_INJECTION +#if SYZ_EXECUTOR static int inject_fault(int nth) { return 0; @@ -638,6 +639,11 @@ static void loop(void) #if SYZ_EXECUTOR || SYZ_USE_TMP_DIR remove_dir(cwdbuf); #endif +#if SYZ_ENABLE_LEAK + // Note: this will fail under setuid sandbox because we don't have + // write permissions for the kmemleak file. + check_leaks(); +#endif } } #else @@ -686,6 +692,16 @@ int main(void) /*MMAP_DATA*/ #endif +#if SYZ_ENABLE_BINFMT_MISC + setup_binfmt_misc(); +#endif +#if SYZ_ENABLE_LEAK + setup_leak(); +#endif +#if SYZ_FAULT_INJECTION + setup_fault(); +#endif + #if SYZ_HANDLE_SEGV install_segv_handler(); #endif @@ -706,6 +722,9 @@ int main(void) } sleep(1000000); #endif +#if !SYZ_PROCS && !SYZ_REPEAT && SYZ_ENABLE_LEAK + check_leaks(); +#endif return 0; } #endif |
