aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/csource.go
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2019-04-10 18:11:44 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-05-31 13:35:25 +0200
commitc054a92ddef28b343db8a733b3e191cf96c28768 (patch)
tree8709cecaf8839ef445a1ad4367ff6ec3dba1fd11 /pkg/csource/csource.go
parenta8482b78fba29ae70c98729401928daccd5201e0 (diff)
pkg/csource: generate timeouts for USB syzcalls
This patch only covers per call timeouts, per prog one is not adjusted yet.
Diffstat (limited to 'pkg/csource/csource.go')
-rw-r--r--pkg/csource/csource.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/pkg/csource/csource.go b/pkg/csource/csource.go
index 75b5a5e02..de99313d2 100644
--- a/pkg/csource/csource.go
+++ b/pkg/csource/csource.go
@@ -73,6 +73,18 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) {
replacements["SANDBOX_FUNC"] = replacements["SYSCALLS"]
replacements["SYSCALLS"] = "unused"
}
+ // Must match timeouts in executor/executor.cc.
+ specialCallTimeouts := map[string]int{
+ "syz_usb_connect": 2000,
+ "syz_usb_disconnect": 200,
+ }
+ timeoutExpr := "45"
+ for i, call := range p.Calls {
+ if timeout, ok := specialCallTimeouts[call.Meta.CallName]; ok {
+ timeoutExpr += fmt.Sprintf(" + (call == %d ? %d : 0)", i, timeout)
+ }
+ }
+ replacements["CALL_TIMEOUT"] = timeoutExpr
result, err := createCommonHeader(p, mmapProg, replacements, opts)
if err != nil {
return nil, err