aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_linux.h
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2019-10-22 13:33:27 +0200
committerMarco Elver <marco.elver@gmail.com>2019-10-22 17:48:18 +0200
commit5681358a2a14647b64cdb97e0d19d3614986d31c (patch)
tree4f3087af9b69ea16b8ac11cd312d5e9a517da43a /executor/common_linux.h
parent4ee855e7ecf0b85cd68ccef760bd9ffb4e4910a5 (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/common_linux.h')
-rw-r--r--executor/common_linux.h26
1 files changed, 25 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