aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ipc
diff options
context:
space:
mode:
authorAndrey Artemiev <artemiev@google.com>2022-08-06 05:17:33 -0700
committerGitHub <noreply@github.com>2022-08-06 14:17:33 +0200
commit88e3a1226bc591d81c1fb98e83cb63cd4f341c6e (patch)
tree323b7fa492a8d9698e432c1d3bd4514771fc3252 /pkg/ipc
parente853abd9a2542fcccb8e1a23eb8ae475500ecaf9 (diff)
pkg/csource, pkg/instance, pkg/ipc, pkg/mgrconfig, tools/syz-prog2c, syz-manager: introduce a new setting 'sandbox_arg' (#3263)
Diffstat (limited to 'pkg/ipc')
-rw-r--r--pkg/ipc/ipc.go17
-rw-r--r--pkg/ipc/ipc_test.go2
-rw-r--r--pkg/ipc/ipcconfig/ipcconfig.go14
3 files changed, 20 insertions, 13 deletions
diff --git a/pkg/ipc/ipc.go b/pkg/ipc/ipc.go
index 839fdcd4c..5537ce0f8 100644
--- a/pkg/ipc/ipc.go
+++ b/pkg/ipc/ipc.go
@@ -70,7 +70,8 @@ type Config struct {
UseForkServer bool // use extended protocol with handshake
// Flags are configuation flags, defined above.
- Flags EnvFlags
+ Flags EnvFlags
+ SandboxArg int
Timeouts targets.Timeouts
}
@@ -504,9 +505,10 @@ const (
)
type handshakeReq struct {
- magic uint64
- flags uint64 // env flags
- pid uint64
+ magic uint64
+ flags uint64 // env flags
+ pid uint64
+ sandboxArg uint64
}
type handshakeReply struct {
@@ -686,9 +688,10 @@ func (c *command) close() {
// handshake sends handshakeReq and waits for handshakeReply.
func (c *command) handshake() error {
req := &handshakeReq{
- magic: inMagic,
- flags: uint64(c.config.Flags),
- pid: uint64(c.pid),
+ magic: inMagic,
+ flags: uint64(c.config.Flags),
+ pid: uint64(c.pid),
+ sandboxArg: uint64(c.config.SandboxArg),
}
reqData := (*[unsafe.Sizeof(*req)]byte)(unsafe.Pointer(req))[:]
if _, err := c.outwp.Write(reqData); err != nil {
diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go
index fd89eae9b..3456852c5 100644
--- a/pkg/ipc/ipc_test.go
+++ b/pkg/ipc/ipc_test.go
@@ -103,6 +103,7 @@ func TestExecute(t *testing.T) {
UseShmem: useShmem,
UseForkServer: useForkServer,
Timeouts: timeouts,
+ SandboxArg: 0,
}
env, err := MakeEnv(cfg, 0)
if err != nil {
@@ -144,6 +145,7 @@ func TestParallel(t *testing.T) {
UseShmem: useShmem,
UseForkServer: useForkServer,
Timeouts: timeouts,
+ SandboxArg: 0,
}
const P = 10
errs := make(chan error, P)
diff --git a/pkg/ipc/ipcconfig/ipcconfig.go b/pkg/ipc/ipcconfig/ipcconfig.go
index 5be4d4b39..15e1dfde0 100644
--- a/pkg/ipc/ipcconfig/ipcconfig.go
+++ b/pkg/ipc/ipcconfig/ipcconfig.go
@@ -12,12 +12,13 @@ import (
)
var (
- flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary")
- flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor")
- flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)")
- flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace/android)")
- flagDebug = flag.Bool("debug", false, "debug output from executor")
- flagSlowdown = flag.Int("slowdown", 1, "execution slowdown caused by emulation/instrumentation")
+ flagExecutor = flag.String("executor", "./syz-executor", "path to executor binary")
+ flagThreaded = flag.Bool("threaded", true, "use threaded mode in executor")
+ flagSignal = flag.Bool("cover", false, "collect feedback signals (coverage)")
+ flagSandbox = flag.String("sandbox", "none", "sandbox for fuzzing (none/setuid/namespace/android)")
+ flagSandboxArg = flag.Int("sandbox_arg", 0, "argument for sandbox runner to adjust it via config")
+ flagDebug = flag.Bool("debug", false, "debug output from executor")
+ flagSlowdown = flag.Int("slowdown", 1, "execution slowdown caused by emulation/instrumentation")
)
func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) {
@@ -36,6 +37,7 @@ func Default(target *prog.Target) (*ipc.Config, *ipc.ExecOpts, error) {
if err != nil {
return nil, nil, err
}
+ c.SandboxArg = *flagSandboxArg
c.Flags |= sandboxFlags
c.UseShmem = sysTarget.ExecutorUsesShmem
c.UseForkServer = sysTarget.ExecutorUsesForkServer