diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-12-10 14:47:32 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-12-10 16:37:02 +0100 |
| commit | 593b260b0233013ce7bbd5acf39263ab83244a14 (patch) | |
| tree | 9aa36ad33f214904d9285b532e7810161ed8e880 /pkg | |
| parent | 083e78159dfe39202cfd867a558a1ec6487ec476 (diff) | |
pkg/ipc: move sandbox helpers from ipcconfig
Currently syz-runtest fails to start because -debug flag is defined
both in syz-runtest and ipcconfig.
But moving sandbox functions we prevent ipcconfig from being imported into syz-runtest.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/ipc/ipc.go | 26 | ||||
| -rw-r--r-- | pkg/ipc/ipcconfig/ipcconfig.go | 29 | ||||
| -rw-r--r-- | pkg/runtest/run.go | 3 |
3 files changed, 28 insertions, 30 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go index 0db32dfb9..fdf400096 100644 --- a/pkg/ipc/ipc.go +++ b/pkg/ipc/ipc.go @@ -127,6 +127,32 @@ const ( compConstMask = 1 ) +func SandboxToFlags(sandbox string) (EnvFlags, error) { + switch sandbox { + case "none": + return 0, nil + case "setuid": + return FlagSandboxSetuid, nil + case "namespace": + return FlagSandboxNamespace, nil + case "android_untrusted_app": + return FlagSandboxAndroidUntrustedApp, nil + default: + return 0, fmt.Errorf("sandbox must contain one of none/setuid/namespace/android_untrusted_app") + } +} + +func FlagsToSandbox(flags EnvFlags) string { + if flags&FlagSandboxSetuid != 0 { + return "setuid" + } else if flags&FlagSandboxNamespace != 0 { + return "namespace" + } else if flags&FlagSandboxAndroidUntrustedApp != 0 { + return "android_untrusted_app" + } + return "none" +} + func MakeEnv(config *Config, pid int) (*Env, error) { var inf, outf *os.File var inmem, outmem []byte diff --git a/pkg/ipc/ipcconfig/ipcconfig.go b/pkg/ipc/ipcconfig/ipcconfig.go index b94579102..f2bd2028e 100644 --- a/pkg/ipc/ipcconfig/ipcconfig.go +++ b/pkg/ipc/ipcconfig/ipcconfig.go @@ -5,7 +5,6 @@ package ipcconfig import ( "flag" - "fmt" "github.com/google/syzkaller/pkg/ipc" "github.com/google/syzkaller/prog" @@ -33,7 +32,7 @@ func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) { if *flagDebug { c.Flags |= ipc.FlagDebug } - sandboxFlags, err := SandboxToFlags(*flagSandbox) + sandboxFlags, err := ipc.SandboxToFlags(*flagSandbox) if err != nil { return nil, nil, err } @@ -58,29 +57,3 @@ func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) { return c, opts, nil } - -func SandboxToFlags(sandbox string) (ipc.EnvFlags, error) { - switch sandbox { - case "none": - return 0, nil - case "setuid": - return ipc.FlagSandboxSetuid, nil - case "namespace": - return ipc.FlagSandboxNamespace, nil - case "android_untrusted_app": - return ipc.FlagSandboxAndroidUntrustedApp, nil - default: - return 0, fmt.Errorf("sandbox must contain one of none/setuid/namespace/android_untrusted_app") - } -} - -func FlagsToSandbox(flags ipc.EnvFlags) string { - if flags&ipc.FlagSandboxSetuid != 0 { - return "setuid" - } else if flags&ipc.FlagSandboxNamespace != 0 { - return "namespace" - } else if flags&ipc.FlagSandboxAndroidUntrustedApp != 0 { - return "android_untrusted_app" - } - return "none" -} diff --git a/pkg/runtest/run.go b/pkg/runtest/run.go index cc5697b43..d6543e0b8 100644 --- a/pkg/runtest/run.go +++ b/pkg/runtest/run.go @@ -26,7 +26,6 @@ import ( "github.com/google/syzkaller/pkg/csource" "github.com/google/syzkaller/pkg/host" "github.com/google/syzkaller/pkg/ipc" - "github.com/google/syzkaller/pkg/ipc/ipcconfig" "github.com/google/syzkaller/pkg/osutil" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" @@ -308,7 +307,7 @@ func (ctx *Context) createSyzTest(p *prog.Prog, sandbox string, threaded, cov bo if sysTarget.ExecutorUsesForkServer { cfg.Flags |= ipc.FlagUseForkServer } - sandboxFlags, err := ipcconfig.SandboxToFlags(sandbox) + sandboxFlags, err := ipc.SandboxToFlags(sandbox) if err != nil { return nil, err } |
