Skip to content

Commit 8a71a7a

Browse files
committed
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.
1 parent bf27483 commit 8a71a7a

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

pkg/fuzzer/queue/queue.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,13 @@ func (t *tee) Next() *Request {
566566
return nil
567567
}
568568
t.queue.Submit(&Request{
569-
Prog: req.Prog.Clone(),
569+
// It makes little sense to copy other fields if these requests
570+
// are to be executed in a different environment.
571+
Type: req.Type,
572+
ExecOpts: req.ExecOpts,
573+
Prog: req.Prog.Clone(),
574+
BinaryFile: req.BinaryFile,
575+
GlobPattern: req.GlobPattern,
570576
})
571577
return req
572578
}

pkg/fuzzer/queue/queue_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package queue
66
import (
77
"testing"
88

9+
"github.com/google/syzkaller/pkg/flatrpc"
10+
"github.com/google/syzkaller/prog"
911
"github.com/stretchr/testify/assert"
1012
)
1113

@@ -50,3 +52,30 @@ func TestGlobFiles(t *testing.T) {
5052
r.Output = []byte{'a', 'b', 0, 'c', 0}
5153
assert.Equal(t, r.GlobFiles(), []string{"ab", "c"})
5254
}
55+
56+
func TestTee(t *testing.T) {
57+
base, dup := Plain(), Plain()
58+
59+
tee := Tee(base, dup)
60+
req := &Request{
61+
Prog: &prog.Prog{},
62+
Type: flatrpc.RequestTypeProgram,
63+
ExecOpts: flatrpc.ExecOpts{SandboxArg: 10},
64+
BinaryFile: "file",
65+
GlobPattern: "pattern",
66+
// These must be ignored.
67+
ReturnOutput: true,
68+
Important: true,
69+
}
70+
base.Submit(req)
71+
72+
origReq := tee.Next()
73+
assert.Equal(t, req, origReq)
74+
copy := dup.Next()
75+
assert.Equal(t, req.Type, copy.Type)
76+
assert.Equal(t, req.ExecOpts, copy.ExecOpts)
77+
assert.Equal(t, req.BinaryFile, copy.BinaryFile)
78+
assert.Equal(t, req.GlobPattern, copy.GlobPattern)
79+
assert.Empty(t, copy.ReturnOutput)
80+
assert.Empty(t, copy.Important)
81+
}

0 commit comments

Comments
 (0)