aboutsummaryrefslogtreecommitdiffstats
path: root/csource
diff options
context:
space:
mode:
authorAndrey Konovalov <andreyknvl@google.com>2017-05-18 16:08:43 +0200
committerAndrey Konovalov <andreyknvl@google.com>2017-06-12 19:48:23 +0200
commit4d1df73af9a6d40d3111e3f2a7dfb9f138fbde4b (patch)
tree48e66cf8d6f91fa3bcabc60ee94ca070befef0af /csource
parent10c9064bfc4890e5895057021280a0558131e3eb (diff)
csource: force enable tun flag when required
Diffstat (limited to 'csource')
-rw-r--r--csource/common.go12
-rw-r--r--csource/csource.go16
2 files changed, 18 insertions, 10 deletions
diff --git a/csource/common.go b/csource/common.go
index 8d4a74146..c0abd4412 100644
--- a/csource/common.go
+++ b/csource/common.go
@@ -1536,21 +1536,13 @@ static uintptr_t execute_syscall(int nr, uintptr_t a0, uintptr_t a1, uintptr_t a
case __NR_syz_fuseblk_mount:
return syz_fuseblk_mount(a0, a1, a2, a3, a4, a5, a6, a7);
#endif
-#if defined(__NR_syz_emit_ethernet)
+#ifdef __NR_syz_emit_ethernet
case __NR_syz_emit_ethernet:
-#if defined(SYZ_EXECUTOR) || defined(SYZ_TUN_ENABLE)
return syz_emit_ethernet(a0, a1);
-#else
- return 0;
-#endif
#endif
-#if defined(__NR_syz_extract_tcp_res)
+#ifdef __NR_syz_extract_tcp_res
case __NR_syz_extract_tcp_res:
-#if defined(SYZ_EXECUTOR) || defined(SYZ_TUN_ENABLE)
return syz_extract_tcp_res(a0, a1, a2);
-#else
- return 0;
-#endif
#endif
#ifdef __NR_syz_kvm_setup_cpu
case __NR_syz_kvm_setup_cpu:
diff --git a/csource/csource.go b/csource/csource.go
index ccc235f7e..0a5bcddd7 100644
--- a/csource/csource.go
+++ b/csource/csource.go
@@ -42,6 +42,18 @@ type Options struct {
Repro bool
}
+func RequiresTun(p *prog.Prog) bool {
+ for _, c := range p.Calls {
+ switch c.Meta.CallName {
+ case "syz_emit_ethernet":
+ return true
+ case "syz_extract_tcp_seq":
+ return true
+ }
+ }
+ return false
+}
+
func Write(p *prog.Prog, opts Options) ([]byte, error) {
exec := make([]byte, prog.ExecBufferSize)
if err := p.SerializeForExec(exec, 0); err != nil {
@@ -49,6 +61,10 @@ func Write(p *prog.Prog, opts Options) ([]byte, error) {
}
w := new(bytes.Buffer)
+ if RequiresTun(p) {
+ opts.EnableTun = true
+ }
+
fmt.Fprint(w, "// autogenerated by syzkaller (http://github.com/google/syzkaller)\n\n")
handled := make(map[string]int)