diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-09-20 21:18:36 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-09-20 21:19:29 +0200 |
| commit | 8cb7d3dcfcbe11a6d5682743816409d1c8e8f6a0 (patch) | |
| tree | 75e6dd62ae61ce7986cf4e0e04e9954586033635 /sys | |
| parent | d606e60dfe3d50499812f7d740dae6e727fa9f76 (diff) | |
all: initial support for fuchsia
Nothing works, but builds.
Update #191
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/fuchsia/amd64.go | 27 | ||||
| -rw-r--r-- | sys/fuchsia/arm64.go | 27 | ||||
| -rw-r--r-- | sys/fuchsia/init.go | 35 | ||||
| -rw-r--r-- | sys/fuchsia/sys.txt | 6 | ||||
| -rw-r--r-- | sys/fuchsia/sys_amd64.const | 5 | ||||
| -rw-r--r-- | sys/fuchsia/sys_arm64.const | 5 | ||||
| -rw-r--r-- | sys/linux/386.go | 4 | ||||
| -rw-r--r-- | sys/linux/amd64.go | 4 | ||||
| -rw-r--r-- | sys/linux/arm.go | 4 | ||||
| -rw-r--r-- | sys/linux/arm64.go | 4 | ||||
| -rw-r--r-- | sys/linux/init.go | 161 | ||||
| -rw-r--r-- | sys/linux/ppc64le.go | 4 | ||||
| -rw-r--r-- | sys/syz-sysgen/sysgen.go | 13 | ||||
| -rw-r--r-- | sys/targets/targets.go | 10 |
14 files changed, 174 insertions, 135 deletions
diff --git a/sys/fuchsia/amd64.go b/sys/fuchsia/amd64.go new file mode 100644 index 000000000..eb51d797d --- /dev/null +++ b/sys/fuchsia/amd64.go @@ -0,0 +1,27 @@ +// AUTOGENERATED FILE +package fuchsia + +import . "github.com/google/syzkaller/prog" + +func init() { + RegisterTarget(&Target{OS: "fuchsia", Arch: "amd64", Revision: revision_amd64, PtrSize: 8, Syscalls: syscalls_amd64, Resources: resources_amd64, Structs: structDescs_amd64, Consts: consts_amd64}, initTarget) +} + +var resources_amd64 = []*ResourceDesc(nil) + +var structDescs_amd64 = []*KeyedStruct(nil) + +var syscalls_amd64 = []*Syscall{ + {Name: "mx_time_get", CallName: "mx_time_get", Args: []Type{ + &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "clock_id", FldName: "clock_id", TypeSize: 8}}, Vals: []uint64{0, 1, 2}}, + }}, +} + +var consts_amd64 = []ConstValue{ + {Name: "MX_CLOCK_MONOTONIC"}, + {Name: "MX_CLOCK_THREAD", Value: 2}, + {Name: "MX_CLOCK_UTC", Value: 1}, + {Name: "__NR_mx_time_get"}, +} + +const revision_amd64 = "d65b9adb4853817be6f471df44fc8347ebf6dfc6" diff --git a/sys/fuchsia/arm64.go b/sys/fuchsia/arm64.go new file mode 100644 index 000000000..b39870ffa --- /dev/null +++ b/sys/fuchsia/arm64.go @@ -0,0 +1,27 @@ +// AUTOGENERATED FILE +package fuchsia + +import . "github.com/google/syzkaller/prog" + +func init() { + RegisterTarget(&Target{OS: "fuchsia", Arch: "arm64", Revision: revision_arm64, PtrSize: 8, Syscalls: syscalls_arm64, Resources: resources_arm64, Structs: structDescs_arm64, Consts: consts_arm64}, initTarget) +} + +var resources_arm64 = []*ResourceDesc(nil) + +var structDescs_arm64 = []*KeyedStruct(nil) + +var syscalls_arm64 = []*Syscall{ + {Name: "mx_time_get", CallName: "mx_time_get", Args: []Type{ + &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "clock_id", FldName: "clock_id", TypeSize: 8}}, Vals: []uint64{0, 1, 2}}, + }}, +} + +var consts_arm64 = []ConstValue{ + {Name: "MX_CLOCK_MONOTONIC"}, + {Name: "MX_CLOCK_THREAD", Value: 2}, + {Name: "MX_CLOCK_UTC", Value: 1}, + {Name: "__NR_mx_time_get"}, +} + +const revision_arm64 = "bd2655e6d85f1fecceb1648649e1ad5adda81dc8" diff --git a/sys/fuchsia/init.go b/sys/fuchsia/init.go new file mode 100644 index 000000000..0dfe874cc --- /dev/null +++ b/sys/fuchsia/init.go @@ -0,0 +1,35 @@ +// Copyright 2017 syzkaller project authors. All rights reserved. +// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +package fuchsia + +import ( + "github.com/google/syzkaller/prog" +) + +func initTarget(target *prog.Target) { + arch := &arch{} + + target.PageSize = pageSize + target.DataOffset = dataOffset + target.MmapSyscall = arch.mmapSyscall + target.MakeMmap = arch.makeMmap + target.AnalyzeMmap = arch.analyzeMmap +} + +const ( + pageSize = 4 << 10 + dataOffset = 512 << 20 +) + +type arch struct { +} + +// createMmapCall creates a "normal" mmap call that maps [start, start+npages) page range. +func (arch *arch) makeMmap(start, npages uint64) *prog.Call { + return nil +} + +func (arch *arch) analyzeMmap(c *prog.Call) (start, npages uint64, mapped bool) { + return +} diff --git a/sys/fuchsia/sys.txt b/sys/fuchsia/sys.txt new file mode 100644 index 000000000..543d5da01 --- /dev/null +++ b/sys/fuchsia/sys.txt @@ -0,0 +1,6 @@ +# Copyright 2017 syzkaller project authors. All rights reserved. +# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. + +mx_time_get(clock_id flags[clock_id]) + +clock_id = MX_CLOCK_MONOTONIC, MX_CLOCK_UTC, MX_CLOCK_THREAD diff --git a/sys/fuchsia/sys_amd64.const b/sys/fuchsia/sys_amd64.const new file mode 100644 index 000000000..c6aa53ea0 --- /dev/null +++ b/sys/fuchsia/sys_amd64.const @@ -0,0 +1,5 @@ +__NR_mx_time_get = 0 + +MX_CLOCK_MONOTONIC = 0 +MX_CLOCK_UTC = 1 +MX_CLOCK_THREAD = 2 diff --git a/sys/fuchsia/sys_arm64.const b/sys/fuchsia/sys_arm64.const new file mode 100644 index 000000000..c6aa53ea0 --- /dev/null +++ b/sys/fuchsia/sys_arm64.const @@ -0,0 +1,5 @@ +__NR_mx_time_get = 0 + +MX_CLOCK_MONOTONIC = 0 +MX_CLOCK_UTC = 1 +MX_CLOCK_THREAD = 2 diff --git a/sys/linux/386.go b/sys/linux/386.go index bb166ec6e..431f21d24 100644 --- a/sys/linux/386.go +++ b/sys/linux/386.go @@ -4,7 +4,7 @@ package linux import . "github.com/google/syzkaller/prog" func init() { - initArch(revision_386, syscalls_386, resources_386, structDescs_386, consts_386, "386", 4) + RegisterTarget(&Target{OS: "linux", Arch: "386", Revision: revision_386, PtrSize: 4, Syscalls: syscalls_386, Resources: resources_386, Structs: structDescs_386, Consts: consts_386}, initTarget) } var resources_386 = []*ResourceDesc{ @@ -16734,4 +16734,4 @@ var consts_386 = []ConstValue{ {Name: "__WNOTHREAD", Value: 536870912}, } -const revision_386 = "86d577076d75af98e3c800a3c65bf8e4869e3ea4" +const revision_386 = "7b2f1949d48094cf3369932d0743db166049457b" diff --git a/sys/linux/amd64.go b/sys/linux/amd64.go index f3f058d81..1a43b6760 100644 --- a/sys/linux/amd64.go +++ b/sys/linux/amd64.go @@ -4,7 +4,7 @@ package linux import . "github.com/google/syzkaller/prog" func init() { - initArch(revision_amd64, syscalls_amd64, resources_amd64, structDescs_amd64, consts_amd64, "amd64", 8) + RegisterTarget(&Target{OS: "linux", Arch: "amd64", Revision: revision_amd64, PtrSize: 8, Syscalls: syscalls_amd64, Resources: resources_amd64, Structs: structDescs_amd64, Consts: consts_amd64}, initTarget) } var resources_amd64 = []*ResourceDesc{ @@ -17264,4 +17264,4 @@ var consts_amd64 = []ConstValue{ {Name: "__WNOTHREAD", Value: 536870912}, } -const revision_amd64 = "e482e82186ee2d78bed701630c062b7c5d5b23c6" +const revision_amd64 = "8349df62e623f9c8d8bfaefcc8ba3febf463ce92" diff --git a/sys/linux/arm.go b/sys/linux/arm.go index 0a1509600..5c4fddab6 100644 --- a/sys/linux/arm.go +++ b/sys/linux/arm.go @@ -4,7 +4,7 @@ package linux import . "github.com/google/syzkaller/prog" func init() { - initArch(revision_arm, syscalls_arm, resources_arm, structDescs_arm, consts_arm, "arm", 4) + RegisterTarget(&Target{OS: "linux", Arch: "arm", Revision: revision_arm, PtrSize: 4, Syscalls: syscalls_arm, Resources: resources_arm, Structs: structDescs_arm, Consts: consts_arm}, initTarget) } var resources_arm = []*ResourceDesc{ @@ -16631,4 +16631,4 @@ var consts_arm = []ConstValue{ {Name: "__WNOTHREAD", Value: 536870912}, } -const revision_arm = "41372f11d60aad90c991926434f714d736320cb1" +const revision_arm = "02567c0623e18214f0be8d059aad68c263064645" diff --git a/sys/linux/arm64.go b/sys/linux/arm64.go index 77d20bd0c..39061d67a 100644 --- a/sys/linux/arm64.go +++ b/sys/linux/arm64.go @@ -4,7 +4,7 @@ package linux import . "github.com/google/syzkaller/prog" func init() { - initArch(revision_arm64, syscalls_arm64, resources_arm64, structDescs_arm64, consts_arm64, "arm64", 8) + RegisterTarget(&Target{OS: "linux", Arch: "arm64", Revision: revision_arm64, PtrSize: 8, Syscalls: syscalls_arm64, Resources: resources_arm64, Structs: structDescs_arm64, Consts: consts_arm64}, initTarget) } var resources_arm64 = []*ResourceDesc{ @@ -16641,4 +16641,4 @@ var consts_arm64 = []ConstValue{ {Name: "__WNOTHREAD", Value: 536870912}, } -const revision_arm64 = "3424aa8d1e2be36f2a093d39f49a45b6904827e0" +const revision_arm64 = "0709fe60bdd20ea30d937d14615a40269fadb2b8" diff --git a/sys/linux/init.go b/sys/linux/init.go index 509e2ab04..c727cb5b2 100644 --- a/sys/linux/init.go +++ b/sys/linux/init.go @@ -9,29 +9,48 @@ import ( "github.com/google/syzkaller/prog" ) -func initArch(rev string, syscalls []*prog.Syscall, resources []*prog.ResourceDesc, - structDescs []*prog.KeyedStruct, consts []prog.ConstValue, archName string, ptrSize uint64) { - arch := makeArch(syscalls, resources, structDescs, consts, archName) - target := &prog.Target{ - OS: "linux", - Arch: archName, - Revision: rev, - PtrSize: ptrSize, - PageSize: pageSize, - DataOffset: dataOffset, - Syscalls: syscalls, - Resources: resources, - MmapSyscall: arch.mmapSyscall, - MakeMmap: arch.makeMmap, - AnalyzeMmap: arch.analyzeMmap, - SanitizeCall: arch.sanitizeCall, - SpecialStructs: map[string]func(g *prog.Gen, typ *prog.StructType, old *prog.GroupArg) (prog.Arg, []*prog.Call){ - "timespec": arch.generateTimespec, - "timeval": arch.generateTimespec, - }, - StringDictionary: stringDictionary, +func initTarget(target *prog.Target) { + arch := &arch{ + mmapSyscall: target.SyscallMap["mmap"], + clockGettimeSyscall: target.SyscallMap["clock_gettime"], + PROT_READ: target.ConstMap["PROT_READ"], + PROT_WRITE: target.ConstMap["PROT_WRITE"], + MAP_ANONYMOUS: target.ConstMap["MAP_ANONYMOUS"], + MAP_PRIVATE: target.ConstMap["MAP_PRIVATE"], + MAP_FIXED: target.ConstMap["MAP_FIXED"], + MREMAP_MAYMOVE: target.ConstMap["MREMAP_MAYMOVE"], + MREMAP_FIXED: target.ConstMap["MREMAP_FIXED"], + S_IFREG: target.ConstMap["S_IFREG"], + S_IFCHR: target.ConstMap["S_IFCHR"], + S_IFBLK: target.ConstMap["S_IFBLK"], + S_IFIFO: target.ConstMap["S_IFIFO"], + S_IFSOCK: target.ConstMap["S_IFSOCK"], + SYSLOG_ACTION_CONSOLE_OFF: target.ConstMap["SYSLOG_ACTION_CONSOLE_OFF"], + SYSLOG_ACTION_CONSOLE_ON: target.ConstMap["SYSLOG_ACTION_CONSOLE_ON"], + SYSLOG_ACTION_SIZE_UNREAD: target.ConstMap["SYSLOG_ACTION_SIZE_UNREAD"], + FIFREEZE: target.ConstMap["FIFREEZE"], + FITHAW: target.ConstMap["FITHAW"], + PTRACE_TRACEME: target.ConstMap["PTRACE_TRACEME"], + CLOCK_REALTIME: target.ConstMap["CLOCK_REALTIME"], + } + + target.PageSize = pageSize + target.DataOffset = dataOffset + target.MmapSyscall = arch.mmapSyscall + target.MakeMmap = arch.makeMmap + target.AnalyzeMmap = arch.analyzeMmap + target.SanitizeCall = arch.sanitizeCall + target.SpecialStructs = map[string]func(g *prog.Gen, typ *prog.StructType, old *prog.GroupArg) (prog.Arg, []*prog.Call){ + "timespec": arch.generateTimespec, + "timeval": arch.generateTimespec, + } + target.StringDictionary = stringDictionary + + if target.Arch == runtime.GOARCH { + KCOV_INIT_TRACE = uintptr(target.ConstMap["KCOV_INIT_TRACE"]) + KCOV_ENABLE = uintptr(target.ConstMap["KCOV_ENABLE"]) + KCOV_TRACE_CMP = uintptr(target.ConstMap["KCOV_TRACE_CMP"]) } - prog.RegisterTarget(target) } const ( @@ -263,101 +282,3 @@ func (arch *arch) generateTimespec(g *prog.Gen, typ *prog.StructType, old *prog. } return } - -func makeArch(syscalls []*prog.Syscall, resources []*prog.ResourceDesc, - structDescs []*prog.KeyedStruct, consts []prog.ConstValue, archName string) *arch { - resourceMap := make(map[string]*prog.ResourceDesc) - for _, res := range resources { - resourceMap[res.Name] = res - } - - keyedStructs := make(map[prog.StructKey]*prog.StructDesc) - for _, desc := range structDescs { - keyedStructs[desc.Key] = desc.Desc - } - - arch := &arch{} - for _, c := range syscalls { - prog.ForeachType(c, func(t0 prog.Type) { - switch t := t0.(type) { - case *prog.ResourceType: - t.Desc = resourceMap[t.TypeName] - if t.Desc == nil { - panic("no resource desc") - } - case *prog.StructType: - t.StructDesc = keyedStructs[t.Key] - if t.StructDesc == nil { - panic("no struct desc") - } - case *prog.UnionType: - t.StructDesc = keyedStructs[t.Key] - if t.StructDesc == nil { - panic("no union desc") - } - } - }) - switch c.Name { - case "mmap": - arch.mmapSyscall = c - case "clock_gettime": - arch.clockGettimeSyscall = c - } - } - - for _, c := range consts { - switch c.Name { - case "KCOV_INIT_TRACE": - if archName == runtime.GOARCH { - KCOV_INIT_TRACE = uintptr(c.Value) - } - case "KCOV_ENABLE": - if archName == runtime.GOARCH { - KCOV_ENABLE = uintptr(c.Value) - } - case "KCOV_TRACE_CMP": - if archName == runtime.GOARCH { - KCOV_TRACE_CMP = uintptr(c.Value) - } - case "PROT_READ": - arch.PROT_READ = c.Value - case "PROT_WRITE": - arch.PROT_WRITE = c.Value - case "MAP_ANONYMOUS": - arch.MAP_ANONYMOUS = c.Value - case "MAP_PRIVATE": - arch.MAP_PRIVATE = c.Value - case "MAP_FIXED": - arch.MAP_FIXED = c.Value - case "MREMAP_MAYMOVE": - arch.MREMAP_MAYMOVE = c.Value - case "MREMAP_FIXED": - arch.MREMAP_FIXED = c.Value - case "S_IFREG": - arch.S_IFREG = c.Value - case "S_IFCHR": - arch.S_IFCHR = c.Value - case "S_IFBLK": - arch.S_IFBLK = c.Value - case "S_IFIFO": - arch.S_IFIFO = c.Value - case "S_IFSOCK": - arch.S_IFSOCK = c.Value - case "SYSLOG_ACTION_CONSOLE_OFF": - arch.SYSLOG_ACTION_CONSOLE_OFF = c.Value - case "SYSLOG_ACTION_CONSOLE_ON": - arch.SYSLOG_ACTION_CONSOLE_ON = c.Value - case "SYSLOG_ACTION_SIZE_UNREAD": - arch.SYSLOG_ACTION_SIZE_UNREAD = c.Value - case "FIFREEZE": - arch.FIFREEZE = c.Value - case "FITHAW": - arch.FITHAW = c.Value - case "PTRACE_TRACEME": - arch.PTRACE_TRACEME = c.Value - case "CLOCK_REALTIME": - arch.CLOCK_REALTIME = c.Value - } - } - return arch -} diff --git a/sys/linux/ppc64le.go b/sys/linux/ppc64le.go index 6686885b5..1c02c5a08 100644 --- a/sys/linux/ppc64le.go +++ b/sys/linux/ppc64le.go @@ -4,7 +4,7 @@ package linux import . "github.com/google/syzkaller/prog" func init() { - initArch(revision_ppc64le, syscalls_ppc64le, resources_ppc64le, structDescs_ppc64le, consts_ppc64le, "ppc64le", 8) + RegisterTarget(&Target{OS: "linux", Arch: "ppc64le", Revision: revision_ppc64le, PtrSize: 8, Syscalls: syscalls_ppc64le, Resources: resources_ppc64le, Structs: structDescs_ppc64le, Consts: consts_ppc64le}, initTarget) } var resources_ppc64le = []*ResourceDesc{ @@ -16330,4 +16330,4 @@ var consts_ppc64le = []ConstValue{ {Name: "__WNOTHREAD", Value: 536870912}, } -const revision_ppc64le = "0af6f5872777fdaf20c06a1f982df39659c46b6a" +const revision_ppc64le = "8bfb8686625fa3398eb8d1a5d66834dec0d3fa06" diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index 56ad15f46..3aa98a16a 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -113,7 +113,7 @@ func main() { } } - writeExecutorSyscalls(syscallArchs) + writeExecutorSyscalls(OS, syscallArchs) } if *flagMemProfile != "" { @@ -135,8 +135,11 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint fmt.Fprintf(out, "import . \"github.com/google/syzkaller/prog\"\n\n") fmt.Fprintf(out, "func init() {\n") - fmt.Fprintf(out, "\tinitArch(revision_%v, syscalls_%v, resources_%v, structDescs_%v, consts_%v, %q, %v)\n", - target.Arch, target.Arch, target.Arch, target.Arch, target.Arch, target.Arch, target.PtrSize) + fmt.Fprintf(out, "\tRegisterTarget(&Target{OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v,"+ + "Syscalls: syscalls_%v, Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}, "+ + "initTarget)\n", + target.OS, target.Arch, target.Arch, target.PtrSize, + target.Arch, target.Arch, target.Arch, target.Arch) fmt.Fprintf(out, "}\n\n") fmt.Fprintf(out, "var resources_%v = ", target.Arch) @@ -203,13 +206,13 @@ func generateExecutorSyscalls(target *targets.Target, syscalls []*prog.Syscall, return buf.Bytes() } -func writeExecutorSyscalls(archs [][]byte) { +func writeExecutorSyscalls(OS string, archs [][]byte) { buf := new(bytes.Buffer) buf.WriteString(syscallsTempl) for _, arch := range archs { buf.Write(arch) } - writeFile("executor/syscalls.h", buf.Bytes()) + writeFile(filepath.Join("executor", fmt.Sprintf("syscalls_%v.h", OS)), buf.Bytes()) } func writeSource(file string, data []byte) { diff --git a/sys/targets/targets.go b/sys/targets/targets.go index 07f3ee8a7..6c5028c1d 100644 --- a/sys/targets/targets.go +++ b/sys/targets/targets.go @@ -62,6 +62,16 @@ var List = map[string]map[string]*Target{ KernelHeaderArch: "powerpc", }, }, + "fuchsia": map[string]*Target{ + "amd64": { + PtrSize: 8, + CArch: []string{"__x86_64__"}, + }, + "arm64": { + PtrSize: 8, + CArch: []string{"__aarch64__"}, + }, + }, } func init() { |
