From 9e8eaa75a18a5cf8102e862be692c0781759e51b Mon Sep 17 00:00:00 2001 From: Kris Alder Date: Mon, 7 Mar 2022 23:00:21 +0000 Subject: pkg/host: only try enabled syscalls when starting syz-fuzzer When syz-fuzzer starts, it tries all syscalls to filter out any that are not supported. This process should include only the syscalls that are enabled using the 'enable_syscalls' and 'disable_syscalls' fields in syz-manager's config. This is useful for fuzzing Cuttlefish devices, for example, where the 'vhost_vsock' syscall needs to be excluded from fuzzing and from this test. --- pkg/host/syscalls_linux_test.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'pkg/host/syscalls_linux_test.go') diff --git a/pkg/host/syscalls_linux_test.go b/pkg/host/syscalls_linux_test.go index 5fc87377c..97f11c25f 100644 --- a/pkg/host/syscalls_linux_test.go +++ b/pkg/host/syscalls_linux_test.go @@ -22,10 +22,6 @@ func TestSupportedSyscalls(t *testing.T) { if err != nil { t.Fatal(err) } - supp, _, err := DetectSupportedSyscalls(target, "none") - if err != nil { - t.Skipf("skipping: %v", err) - } // These are safe to execute with invalid arguments. safe := []string{ "memfd_create", @@ -37,18 +33,26 @@ func TestSupportedSyscalls(t *testing.T) { "write", "stat", } + enabled := make(map[*prog.Syscall]bool) for _, name := range safe { c := target.SyscallMap[name] if c == nil { t.Fatalf("can't find syscall '%v'", name) } + enabled[c] = true + } + supp, _, err := DetectSupportedSyscalls(target, "none", enabled) + if err != nil { + t.Skipf("skipping: %v", err) + } + for c := range enabled { a := ^uintptr(0) - 4097 // hopefully invalid _, _, err := syscall.Syscall6(uintptr(c.NR), a, a, a, a, a, a) if err == 0 { - t.Fatalf("%v did not fail", name) + t.Fatalf("%v did not fail", c.Name) } if ok := err != syscall.ENOSYS; ok != supp[c] { - t.Fatalf("syscall %v: perse=%v kallsyms=%v", name, ok, supp[c]) + t.Fatalf("syscall %v: perse=%v kallsyms=%v", c.Name, ok, supp[c]) } } } -- cgit mrf-deployment