From 85b1f93f8dbbc767c564e494a6353aa3517d5d49 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 16 Oct 2017 12:18:50 +0200 Subject: executor, pkg/ipc: unify ipc protocol between linux and other OSes We currently use more complex and functional protocol on linux, and a simple ad-hoc protocol on other OSes. This leads to code duplication in both ipc and executor. Linux supports coverage, shared memory communication and fork server, which would also be useful for most other OSes. Unify communication protocol and parametrize it by (1) use of shmem or only pipes, (2) use of fork server. This reduces duplication in ipc and executor and will allow to support the useful features for other OSes easily. Finally, this fixes akaros support as it currently uses syz-stress running on host (linux) and executor running on akaros. --- pkg/host/host_akaros.go | 4 ++++ pkg/host/host_freebsd.go | 4 ++++ pkg/host/host_fuchsia.go | 4 ++++ pkg/host/host_linux.go | 11 +++++++++++ pkg/host/host_windows.go | 4 ++++ 5 files changed, 27 insertions(+) (limited to 'pkg/host') diff --git a/pkg/host/host_akaros.go b/pkg/host/host_akaros.go index 4e3065d91..6c3fbb6d3 100644 --- a/pkg/host/host_akaros.go +++ b/pkg/host/host_akaros.go @@ -17,3 +17,7 @@ func DetectSupportedSyscalls(target *prog.Target) (map[*prog.Syscall]bool, error } return supported, nil } + +func EnableFaultInjection() error { + return nil +} diff --git a/pkg/host/host_freebsd.go b/pkg/host/host_freebsd.go index b931b5c6c..d2745e376 100644 --- a/pkg/host/host_freebsd.go +++ b/pkg/host/host_freebsd.go @@ -15,3 +15,7 @@ func DetectSupportedSyscalls(target *prog.Target) (map[*prog.Syscall]bool, error } return supported, nil } + +func EnableFaultInjection() error { + return nil +} diff --git a/pkg/host/host_fuchsia.go b/pkg/host/host_fuchsia.go index 7f4abc47b..37cf8b847 100644 --- a/pkg/host/host_fuchsia.go +++ b/pkg/host/host_fuchsia.go @@ -17,3 +17,7 @@ func DetectSupportedSyscalls(target *prog.Target) (map[*prog.Syscall]bool, error } return supported, nil } + +func EnableFaultInjection() error { + return nil +} diff --git a/pkg/host/host_linux.go b/pkg/host/host_linux.go index ef301e2dc..6da153f2d 100644 --- a/pkg/host/host_linux.go +++ b/pkg/host/host_linux.go @@ -5,6 +5,7 @@ package host import ( "bytes" + "fmt" "io/ioutil" "runtime" "strconv" @@ -159,3 +160,13 @@ func extractStringConst(typ prog.Type) (string, bool) { v = v[:len(v)-1] // string terminating \x00 return v, true } + +func EnableFaultInjection() error { + if err := osutil.WriteFile("/sys/kernel/debug/failslab/ignore-gfp-wait", []byte("N")); err != nil { + return fmt.Errorf("failed to write /sys/kernel/debug/failslab/ignore-gfp-wait: %v", err) + } + if err := osutil.WriteFile("/sys/kernel/debug/fail_futex/ignore-private", []byte("N")); err != nil { + return fmt.Errorf("failed to write /sys/kernel/debug/fail_futex/ignore-private: %v", err) + } + return nil +} diff --git a/pkg/host/host_windows.go b/pkg/host/host_windows.go index b931b5c6c..d2745e376 100644 --- a/pkg/host/host_windows.go +++ b/pkg/host/host_windows.go @@ -15,3 +15,7 @@ func DetectSupportedSyscalls(target *prog.Target) (map[*prog.Syscall]bool, error } return supported, nil } + +func EnableFaultInjection() error { + return nil +} -- cgit mrf-deployment