diff options
| author | Marco Elver <elver@google.com> | 2019-10-22 13:33:27 +0200 |
|---|---|---|
| committer | Marco Elver <marco.elver@gmail.com> | 2019-10-22 17:48:18 +0200 |
| commit | 5681358a2a14647b64cdb97e0d19d3614986d31c (patch) | |
| tree | 4f3087af9b69ea16b8ac11cd312d5e9a517da43a /executor | |
| parent | 4ee855e7ecf0b85cd68ccef760bd9ffb4e4910a5 (diff) | |
syz-fuzzer, executor: Add support for blacklisting data race frames
This adds support to add frames that have already been in data races, to
the KCSAN report blacklist.
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common_linux.h | 26 | ||||
| -rw-r--r-- | executor/executor.cc | 8 |
2 files changed, 33 insertions, 1 deletions
diff --git a/executor/common_linux.h b/executor/common_linux.h index 5888b65cf..b56453510 100644 --- a/executor/common_linux.h +++ b/executor/common_linux.h @@ -2784,9 +2784,33 @@ static void setup_binfmt_misc() #endif #if SYZ_EXECUTOR || SYZ_ENABLE_KCSAN +#define KCSAN_DEBUGFS_FILE "/sys/kernel/debug/kcsan" + static void setup_kcsan() { - if (!write_file("/sys/kernel/debug/kcsan", "on")) + if (!write_file(KCSAN_DEBUGFS_FILE, "on")) fail("failed to enable KCSAN"); } + +#if SYZ_EXECUTOR // currently only used by executor +static void setup_kcsan_filterlist(char** frames, int nframes, bool blacklist) +{ + int fd = open(KCSAN_DEBUGFS_FILE, O_WRONLY); + if (fd == -1) + fail("failed to open(\"%s\")", KCSAN_DEBUGFS_FILE); + + const char* const filtertype = blacklist ? "blacklist" : "whitelist"; + printf("adding functions to KCSAN %s: ", filtertype); + dprintf(fd, "%s\n", filtertype); + for (int i = 0; i < nframes; ++i) { + printf("'%s' ", frames[i]); + dprintf(fd, "!%s\n", frames[i]); + } + printf("\n"); + + close(fd); +} + +#define SYZ_HAVE_KCSAN 1 +#endif #endif diff --git a/executor/executor.cc b/executor/executor.cc index 1f51ec279..30d497ea9 100644 --- a/executor/executor.cc +++ b/executor/executor.cc @@ -347,6 +347,14 @@ int main(int argc, char** argv) #endif return 0; } + if (argc >= 2 && strcmp(argv[1], "setup_kcsan_blacklist") == 0) { +#if SYZ_HAVE_KCSAN + setup_kcsan_filterlist(argv + 2, argc - 2, /*blacklist=*/true); +#else + fail("KCSAN is not implemented"); +#endif + return 0; + } if (argc == 2 && strcmp(argv[1], "test") == 0) return run_tests(); |
