aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource
diff options
context:
space:
mode:
authorMarco Elver <elver@google.com>2019-10-04 13:43:02 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-10-04 13:44:09 +0200
commitb2f369e56e13dc135d57c53210ea7ab38b239e94 (patch)
treef740d97da76dbe3c9b1e2de6409e4e6f94c1e375 /pkg/csource
parentfc17ba4941e5e2cae9663b84e13627981c29d381 (diff)
executor, host, csource: Add support to enable KCSAN
By default, the current KCSAN .config does not enable KCSAN during boot, since we encounter races during boot which would prevent syzkaller from ever executing. This adds support to detect if KCSAN is available, and enables it on the fuzzer host.
Diffstat (limited to 'pkg/csource')
-rw-r--r--pkg/csource/common.go1
-rw-r--r--pkg/csource/generated.go11
-rw-r--r--pkg/csource/options.go6
3 files changed, 17 insertions, 1 deletions
diff --git a/pkg/csource/common.go b/pkg/csource/common.go
index f4da50b85..e537ed724 100644
--- a/pkg/csource/common.go
+++ b/pkg/csource/common.go
@@ -94,6 +94,7 @@ func defineList(p, mmapProg *prog.Prog, opts Options) (defines []string) {
"SYZ_RESET_NET_NAMESPACE": opts.EnableNetReset,
"SYZ_ENABLE_BINFMT_MISC": opts.EnableBinfmtMisc,
"SYZ_ENABLE_CLOSE_FDS": opts.EnableCloseFds,
+ "SYZ_ENABLE_KCSAN": opts.EnableKCSAN,
"SYZ_USE_TMP_DIR": opts.UseTmpDir,
"SYZ_HANDLE_SEGV": opts.HandleSegv,
"SYZ_REPRO": opts.Repro,
diff --git a/pkg/csource/generated.go b/pkg/csource/generated.go
index a8bebb9a9..c216e0973 100644
--- a/pkg/csource/generated.go
+++ b/pkg/csource/generated.go
@@ -5193,6 +5193,14 @@ static void setup_binfmt_misc()
}
#endif
+#if SYZ_EXECUTOR || SYZ_ENABLE_KCSAN
+static void setup_kcsan()
+{
+ if (!write_file("/proc/kcsaninfo", "on"))
+ fail("failed to enable KCSAN");
+}
+#endif
+
#elif GOOS_test
#include <stdlib.h>
@@ -5671,6 +5679,9 @@ int main(void)
#if SYZ_FAULT_INJECTION
setup_fault();
#endif
+#if SYZ_ENABLE_KCSAN
+ setup_kcsan();
+#endif
#if SYZ_HANDLE_SEGV
install_segv_handler();
diff --git a/pkg/csource/options.go b/pkg/csource/options.go
index 2eda3acc6..7ad8c1d9c 100644
--- a/pkg/csource/options.go
+++ b/pkg/csource/options.go
@@ -37,6 +37,7 @@ type Options struct {
EnableCgroups bool `json:"cgroups,omitempty"`
EnableBinfmtMisc bool `json:"binfmt_misc,omitempty"`
EnableCloseFds bool `json:"close_fds"`
+ EnableKCSAN bool `json:"kcsan,omitempty"`
UseTmpDir bool `json:"tmpdir,omitempty"`
HandleSegv bool `json:"segv,omitempty"`
@@ -121,7 +122,10 @@ func (opts Options) checkLinuxOnly(OS string) error {
return fmt.Errorf("option EnableBinfmtMisc is not supported on %v", OS)
}
if opts.EnableCloseFds {
- return fmt.Errorf("EnableCloseFds is not supported on %v", OS)
+ return fmt.Errorf("option EnableCloseFds is not supported on %v", OS)
+ }
+ if opts.EnableKCSAN {
+ return fmt.Errorf("option EnableKCSAN is not supported on %v", OS)
}
if opts.Sandbox == sandboxNamespace ||
(opts.Sandbox == sandboxSetuid && !(OS == openbsd || OS == freebsd || OS == netbsd)) ||