From 5701183bd373a3c3c96a86010b67bfecfbddb485 Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Thu, 4 Apr 2019 20:22:49 +0200 Subject: [PATCH] sys/openbsd: add pci descriptions --- executor/defs.h | 2 +- executor/syscalls.h | 4 +++ sys/openbsd/dev_pci.txt | 33 +++++++++++++++++++ sys/openbsd/dev_pci_amd64.const | 7 ++++ sys/openbsd/gen/amd64.go | 57 ++++++++++++++++++++++++++++++++- 5 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 sys/openbsd/dev_pci.txt create mode 100644 sys/openbsd/dev_pci_amd64.const diff --git a/executor/defs.h b/executor/defs.h index 0ee973d3..50e48c8c 100644 --- a/executor/defs.h +++ b/executor/defs.h @@ -130,7 +130,7 @@ #if GOARCH_amd64 #define GOARCH "amd64" -#define SYZ_REVISION "9fc67a9064cfaddb0ab19eb767a060a0050eee68" +#define SYZ_REVISION "66d66a3830b5b4fd591a3693f4ba004395ee7fb6" #define SYZ_EXECUTOR_USES_FORK_SERVER 1 #define SYZ_EXECUTOR_USES_SHMEM 1 #define SYZ_PAGE_SIZE 4096 diff --git a/executor/syscalls.h b/executor/syscalls.h index 43da5941..b86276d1 100644 --- a/executor/syscalls.h +++ b/executor/syscalls.h @@ -14824,6 +14824,9 @@ const call_t syscalls[] = { {"ioctl$KDSETLED", 54}, {"ioctl$KDSETMODE", 54}, {"ioctl$KDSETRAD", 54}, + {"ioctl$PCIOCGETROM", 54}, + {"ioctl$PCIOCREAD", 54}, + {"ioctl$PCIOCWRITE", 54}, {"ioctl$TIOCCBRK", 54}, {"ioctl$TIOCCDTR", 54}, {"ioctl$TIOCCHKVERAUTH", 54}, @@ -14926,6 +14929,7 @@ const call_t syscalls[] = { {"openat", 321}, {"openat$bpf", 321}, {"openat$null", 321}, + {"openat$pci", 321}, {"openat$tty", 321}, {"openat$wsdisplay", 321}, {"openat$wskbd", 321}, diff --git a/sys/openbsd/dev_pci.txt b/sys/openbsd/dev_pci.txt new file mode 100644 index 00000000..b9105800 --- /dev/null +++ b/sys/openbsd/dev_pci.txt @@ -0,0 +1,33 @@ +# Copyright 2019 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. + +include +include +include + +resource fd_pci[fd] + +openat$pci(fd const[AT_FDCWD], file ptr[in, string["/dev/pci"]], flags flags[open_flags], mode const[0]) fd_pci + +ioctl$PCIOCREAD(fd fd_pci, cmd const[PCIOCREAD], arg ptr[out, pci_io]) +ioctl$PCIOCWRITE(fd fd_pci, cmd const[PCIOCWRITE], arg ptr[in, pci_io]) +ioctl$PCIOCGETROM(fd fd_pci, cmd const[PCIOCGETROM], arg ptr[out, pci_rom]) + +pci_io { + pi_sel pcisel + pi_reg int32 + pi_width int32 + pi_data int32 +} + +pci_rom { + pr_sel pcisel + pr_romlen len[pr_rom, int32] + pr_rom ptr[out, array[int32]] +} + +pcisel { + pc_bus int8 + pc_dev int8 + pc_func int8 +} diff --git a/sys/openbsd/dev_pci_amd64.const b/sys/openbsd/dev_pci_amd64.const new file mode 100644 index 00000000..0466fc6c --- /dev/null +++ b/sys/openbsd/dev_pci_amd64.const @@ -0,0 +1,7 @@ +# AUTOGENERATED FILE +AT_FDCWD = 18446744073709551516 +PCIOCGETROM = 3222302725 +PCIOCREAD = 3222302722 +PCIOCWRITE = 3222302723 +SYS_ioctl = 54 +SYS_openat = 321 diff --git a/sys/openbsd/gen/amd64.go b/sys/openbsd/gen/amd64.go index dbaa4371..f6fd1d48 100644 --- a/sys/openbsd/gen/amd64.go +++ b/sys/openbsd/gen/amd64.go @@ -15,6 +15,7 @@ var resources_amd64 = []*ResourceDesc{ {Name: "fd_bpf", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_bpf"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, {Name: "fd_dir", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_dir"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, {Name: "fd_kqueue", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_kqueue"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, + {Name: "fd_pci", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_pci"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, {Name: "fd_tty", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_tty"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, {Name: "fd_wsdisplay", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_wsdisplay"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, {Name: "fd_wskbd", Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4}}}, Kind: []string{"fd", "fd_wskbd"}, Values: []uint64{18446744073709551615, 18446744073709551516}}, @@ -221,6 +222,36 @@ var structDescs_amd64 = []*KeyedStruct{ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "pad0", TypeSize: 8}}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "pad1", TypeSize: 8}}}, }}}, + {Key: StructKey{Name: "pci_io"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "pci_io", TypeSize: 16}, Fields: []Type{ + &StructType{Key: StructKey{Name: "pcisel"}, FldName: "pi_sel"}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 1}}, IsPad: true}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "pi_reg", TypeSize: 4}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "pi_width", TypeSize: 4}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "pi_data", TypeSize: 4}}}, + }}}, + {Key: StructKey{Name: "pci_io", Dir: 1}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "pci_io", TypeSize: 16, ArgDir: 1}, Fields: []Type{ + &StructType{Key: StructKey{Name: "pcisel", Dir: 1}, FldName: "pi_sel"}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 1}}, IsPad: true}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "pi_reg", TypeSize: 4, ArgDir: 1}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "pi_width", TypeSize: 4, ArgDir: 1}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "pi_data", TypeSize: 4, ArgDir: 1}}}, + }}}, + {Key: StructKey{Name: "pci_rom", Dir: 1}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "pci_rom", TypeSize: 16, ArgDir: 1}, Fields: []Type{ + &StructType{Key: StructKey{Name: "pcisel", Dir: 1}, FldName: "pr_sel"}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "pad", TypeSize: 1}}, IsPad: true}, + &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "pr_romlen", TypeSize: 4, ArgDir: 1}}, Buf: "pr_rom"}, + &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "pr_rom", TypeSize: 8}, Type: &ArrayType{TypeCommon: TypeCommon{TypeName: "array", ArgDir: 1, IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", TypeSize: 4, ArgDir: 1}}}}}, + }}}, + {Key: StructKey{Name: "pcisel"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "pcisel", TypeSize: 3}, Fields: []Type{ + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pc_bus", TypeSize: 1}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pc_dev", TypeSize: 1}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pc_func", TypeSize: 1}}}, + }}}, + {Key: StructKey{Name: "pcisel", Dir: 1}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "pcisel", TypeSize: 3, ArgDir: 1}, Fields: []Type{ + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pc_bus", TypeSize: 1, ArgDir: 1}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pc_dev", TypeSize: 1, ArgDir: 1}}}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "pc_func", TypeSize: 1, ArgDir: 1}}}, + }}}, {Key: StructKey{Name: "pipefd", Dir: 1}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "pipefd", TypeSize: 8, ArgDir: 1}, Fields: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "fd", FldName: "rfd", TypeSize: 4, ArgDir: 1}}, &ResourceType{TypeCommon: TypeCommon{TypeName: "fd", FldName: "wfd", TypeSize: 4, ArgDir: 1}}, @@ -1056,6 +1087,21 @@ var syscalls_amd64 = []*Syscall{ &ResourceType{TypeCommon: TypeCommon{TypeName: "fd_wsdisplay", FldName: "fd", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 536890179}, }}, + {NR: 54, Name: "ioctl$PCIOCGETROM", CallName: "ioctl", Args: []Type{ + &ResourceType{TypeCommon: TypeCommon{TypeName: "fd_pci", FldName: "fd", TypeSize: 4}}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 3222302725}, + &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "arg", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "pci_rom", Dir: 1}}}, + }}, + {NR: 54, Name: "ioctl$PCIOCREAD", CallName: "ioctl", Args: []Type{ + &ResourceType{TypeCommon: TypeCommon{TypeName: "fd_pci", FldName: "fd", TypeSize: 4}}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 3222302722}, + &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "arg", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "pci_io", Dir: 1}}}, + }}, + {NR: 54, Name: "ioctl$PCIOCWRITE", CallName: "ioctl", Args: []Type{ + &ResourceType{TypeCommon: TypeCommon{TypeName: "fd_pci", FldName: "fd", TypeSize: 4}}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 3222302723}, + &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "arg", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "pci_io"}}}, + }}, {NR: 54, Name: "ioctl$TIOCCBRK", CallName: "ioctl", MissingArgs: 1, Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "fd_tty", FldName: "fd", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 536900730}, @@ -1548,6 +1594,12 @@ var syscalls_amd64 = []*Syscall{ &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "open_flags", FldName: "flags", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 8, 512, 1024, 2048, 16, 32, 256, 65536, 128, 128, 128, 32768, 131072, 64}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "mode", TypeSize: 8}}}, }, Ret: &ResourceType{TypeCommon: TypeCommon{TypeName: "fd", FldName: "ret", TypeSize: 4, ArgDir: 1}}}, + {NR: 321, Name: "openat$pci", CallName: "openat", Args: []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "fd", TypeSize: 8}}, Val: 18446744073709551516}, + &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "file", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", TypeSize: 9}, Kind: 2, Values: []string{"/dev/pci\x00"}}}, + &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "open_flags", FldName: "flags", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 8, 512, 1024, 2048, 16, 32, 256, 65536, 128, 128, 128, 32768, 131072, 64}}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "mode", TypeSize: 8}}}, + }, Ret: &ResourceType{TypeCommon: TypeCommon{TypeName: "fd_pci", FldName: "ret", TypeSize: 4, ArgDir: 1}}}, {NR: 321, Name: "openat$tty", CallName: "openat", Args: []Type{ &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "fd", TypeSize: 8}}, Val: 18446744073709551516}, &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "file", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", TypeSize: 9}, Kind: 2, Values: []string{"/dev/tty\x00"}}}, @@ -2252,6 +2304,9 @@ var consts_amd64 = []ConstValue{ {Name: "O_SYNC", Value: 128}, {Name: "O_TRUNC", Value: 1024}, {Name: "O_WRONLY", Value: 1}, + {Name: "PCIOCGETROM", Value: 3222302725}, + {Name: "PCIOCREAD", Value: 3222302722}, + {Name: "PCIOCWRITE", Value: 3222302723}, {Name: "POLLERR", Value: 8}, {Name: "POLLHUP", Value: 16}, {Name: "POLLIN", Value: 1}, @@ -2603,4 +2658,4 @@ var consts_amd64 = []ConstValue{ {Name: "__MAP_NOREPLACE", Value: 2048}, } -const revision_amd64 = "9fc67a9064cfaddb0ab19eb767a060a0050eee68" +const revision_amd64 = "66d66a3830b5b4fd591a3693f4ba004395ee7fb6"