diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-08-21 15:53:47 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-08-26 13:14:55 +0000 |
| commit | 8a71a7acb8f7d65994b038587cf2e6d35ed4e5b8 (patch) | |
| tree | 24fda25d6b78072cee36f6f7a253dfbd0d789d84 /pkg | |
| parent | bf27483f963359281b2d9b6d6efd36289f82e282 (diff) | |
pkg/fuzzer/queue: copy more field in Tee
Copy everything that might be important during execution on other
kernels/VM pools. Add a test to verify it.
The functionality is actively used to clone requests in the diff fuzzer.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/fuzzer/queue/queue.go | 8 | ||||
| -rw-r--r-- | pkg/fuzzer/queue/queue_test.go | 29 |
2 files changed, 36 insertions, 1 deletions
diff --git a/pkg/fuzzer/queue/queue.go b/pkg/fuzzer/queue/queue.go index ca2d76092..20509dcb7 100644 --- a/pkg/fuzzer/queue/queue.go +++ b/pkg/fuzzer/queue/queue.go @@ -566,7 +566,13 @@ func (t *tee) Next() *Request { return nil } t.queue.Submit(&Request{ - Prog: req.Prog.Clone(), + // It makes little sense to copy other fields if these requests + // are to be executed in a different environment. + Type: req.Type, + ExecOpts: req.ExecOpts, + Prog: req.Prog.Clone(), + BinaryFile: req.BinaryFile, + GlobPattern: req.GlobPattern, }) return req } diff --git a/pkg/fuzzer/queue/queue_test.go b/pkg/fuzzer/queue/queue_test.go index d1909e50c..49bb92159 100644 --- a/pkg/fuzzer/queue/queue_test.go +++ b/pkg/fuzzer/queue/queue_test.go @@ -6,6 +6,8 @@ package queue import ( "testing" + "github.com/google/syzkaller/pkg/flatrpc" + "github.com/google/syzkaller/prog" "github.com/stretchr/testify/assert" ) @@ -50,3 +52,30 @@ func TestGlobFiles(t *testing.T) { r.Output = []byte{'a', 'b', 0, 'c', 0} assert.Equal(t, r.GlobFiles(), []string{"ab", "c"}) } + +func TestTee(t *testing.T) { + base, dup := Plain(), Plain() + + tee := Tee(base, dup) + req := &Request{ + Prog: &prog.Prog{}, + Type: flatrpc.RequestTypeProgram, + ExecOpts: flatrpc.ExecOpts{SandboxArg: 10}, + BinaryFile: "file", + GlobPattern: "pattern", + // These must be ignored. + ReturnOutput: true, + Important: true, + } + base.Submit(req) + + origReq := tee.Next() + assert.Equal(t, req, origReq) + copy := dup.Next() + assert.Equal(t, req.Type, copy.Type) + assert.Equal(t, req.ExecOpts, copy.ExecOpts) + assert.Equal(t, req.BinaryFile, copy.BinaryFile) + assert.Equal(t, req.GlobPattern, copy.GlobPattern) + assert.Empty(t, copy.ReturnOutput) + assert.Empty(t, copy.Important) +} |
