diff options
| author | Utkarsh Anand <uanand009@gmail.com> | 2017-10-29 09:42:42 +0530 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-10-30 18:57:38 +0100 |
| commit | d84e0ffaecaa8155c24bd6de1f11a291b7e1a908 (patch) | |
| tree | e2dab9d1135418f05939d2402bd5c2caedcea607 /sys | |
| parent | 5b3a76c9f8b55281f244b8f81e48c5b0b935ccc3 (diff) | |
Fix the SYS_SEMCTL value issue for NetBSD
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/netbsd/amd64.go | 24 | ||||
| -rw-r--r-- | sys/netbsd/ipc.txt | 2 | ||||
| -rw-r--r-- | sys/netbsd/ipc_amd64.const | 2 | ||||
| -rw-r--r-- | sys/syz-extract/netbsd.go | 16 |
4 files changed, 27 insertions, 17 deletions
diff --git a/sys/netbsd/amd64.go b/sys/netbsd/amd64.go index 781d0139f..52811449b 100644 --- a/sys/netbsd/amd64.go +++ b/sys/netbsd/amd64.go @@ -176,60 +176,60 @@ var syscalls_amd64 = []*Syscall{ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "vec", TypeSize: 8}, Type: &ArrayType{TypeCommon: TypeCommon{TypeName: "array"}, Type: &StructType{Key: StructKey{Name: "iovec_out"}}}}, &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "vlen", TypeSize: 8}}, Buf: "vec"}, }}, - {ID: 24, NR: 510, Name: "semctl$GETALL", CallName: "semctl", Args: []Type{ + {ID: 24, NR: 442, Name: "semctl$GETALL", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "semnum", TypeSize: 8}}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 6}, &PtrType{TypeCommon: TypeCommon{TypeName: "buffer", FldName: "arg", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{ArgDir: 1}}}, }}, - {ID: 25, NR: 510, Name: "semctl$GETNCNT", CallName: "semctl", Args: []Type{ + {ID: 25, NR: 442, Name: "semctl$GETNCNT", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "sem_sem_id", FldName: "semnum", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 3, 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 3}, &PtrType{TypeCommon: TypeCommon{TypeName: "buffer", FldName: "arg", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{ArgDir: 1}}}, }}, - {ID: 26, NR: 510, Name: "semctl$GETPID", CallName: "semctl", Args: []Type{ + {ID: 26, NR: 442, Name: "semctl$GETPID", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "sem_sem_id", FldName: "semnum", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 3, 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 4}, &PtrType{TypeCommon: TypeCommon{TypeName: "buffer", FldName: "arg", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{ArgDir: 1}}}, }}, - {ID: 27, NR: 510, Name: "semctl$GETVAL", CallName: "semctl", Args: []Type{ + {ID: 27, NR: 442, Name: "semctl$GETVAL", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "sem_sem_id", FldName: "semnum", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 3, 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 5}, &PtrType{TypeCommon: TypeCommon{TypeName: "buffer", FldName: "arg", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{ArgDir: 1}}}, }}, - {ID: 28, NR: 510, Name: "semctl$GETZCNT", CallName: "semctl", Args: []Type{ + {ID: 28, NR: 442, Name: "semctl$GETZCNT", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "sem_sem_id", FldName: "semnum", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 3, 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 7}, &PtrType{TypeCommon: TypeCommon{TypeName: "buffer", FldName: "arg", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{ArgDir: 1}}}, }}, - {ID: 29, NR: 510, Name: "semctl$IPC_RMID", CallName: "semctl", Args: []Type{ + {ID: 29, NR: 442, Name: "semctl$IPC_RMID", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "semnum", TypeSize: 8}}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}}, }}, - {ID: 30, NR: 510, Name: "semctl$IPC_SET", CallName: "semctl", Args: []Type{ + {ID: 30, NR: 442, Name: "semctl$IPC_SET", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "semnum", TypeSize: 8}}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 1}, &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "arg", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "semid_ds"}}}, }}, - {ID: 31, NR: 510, Name: "semctl$IPC_STAT", CallName: "semctl", Args: []Type{ + {ID: 31, NR: 442, Name: "semctl$IPC_STAT", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "semnum", TypeSize: 8}}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 2}, &PtrType{TypeCommon: TypeCommon{TypeName: "buffer", FldName: "arg", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{ArgDir: 1}}}, }}, - {ID: 32, NR: 510, Name: "semctl$SETALL", CallName: "semctl", Args: []Type{ + {ID: 32, NR: 442, Name: "semctl$SETALL", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "semnum", TypeSize: 8}}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 9}, &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "arg", TypeSize: 8}, Type: &ArrayType{TypeCommon: TypeCommon{TypeName: "array"}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16", TypeSize: 2}}}}}, }}, - {ID: 33, NR: 510, Name: "semctl$SETVAL", CallName: "semctl", Args: []Type{ + {ID: 33, NR: 442, Name: "semctl$SETVAL", CallName: "semctl", Args: []Type{ &ResourceType{TypeCommon: TypeCommon{TypeName: "ipc_sem", FldName: "semid", TypeSize: 4}}, &FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "sem_sem_id", FldName: "semnum", TypeSize: 8}}, Vals: []uint64{0, 1, 2, 3, 4}}, &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "cmd", TypeSize: 8}}, Val: 8}, @@ -369,7 +369,7 @@ var consts_amd64 = []ConstValue{ {Name: "SYS_pwritev", Value: 290}, {Name: "SYS_read", Value: 3}, {Name: "SYS_readv", Value: 120}, - {Name: "SYS_semctl", Value: 510}, + {Name: "SYS_semctl", Value: 442}, {Name: "SYS_semget", Value: 221}, {Name: "SYS_semop", Value: 222}, {Name: "SYS_shmat", Value: 228}, @@ -388,4 +388,4 @@ var consts_amd64 = []ConstValue{ {Name: "S_IXUSR", Value: 64}, } -const revision_amd64 = "2720f43fa507fee4cdf71db3cc7418897f7b14fb" +const revision_amd64 = "f0879cb987cc388011c59303da115795c3f00f98" diff --git a/sys/netbsd/ipc.txt b/sys/netbsd/ipc.txt index dc1e4d36e..84c3c347c 100644 --- a/sys/netbsd/ipc.txt +++ b/sys/netbsd/ipc.txt @@ -13,7 +13,7 @@ resource ipc[int32]: 0, 0xffffffffffffffff # TODO: describe ipc syscall -define SYS_semctl 510 +define SYS____semctl50 442 resource ipc_msq[ipc] msgget(key proc[2039379027, 4], flags flags[msgget_flags]) ipc_msq diff --git a/sys/netbsd/ipc_amd64.const b/sys/netbsd/ipc_amd64.const index 826ae6914..69fa49a29 100644 --- a/sys/netbsd/ipc_amd64.const +++ b/sys/netbsd/ipc_amd64.const @@ -20,7 +20,7 @@ SHM_RND = 8192 SYS_msgget = 225 SYS_msgrcv = 227 SYS_msgsnd = 226 -SYS_semctl = 510 +SYS_semctl = 442 SYS_semget = 221 SYS_semop = 222 SYS_shmat = 228 diff --git a/sys/syz-extract/netbsd.go b/sys/syz-extract/netbsd.go index da9e4b4f0..f0af0ba72 100644 --- a/sys/syz-extract/netbsd.go +++ b/sys/syz-extract/netbsd.go @@ -7,6 +7,7 @@ import ( "fmt" "os" "path/filepath" + "strings" "github.com/google/syzkaller/pkg/compiler" ) @@ -55,9 +56,18 @@ func (*netbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]uin // try to extract consts with these prefixes as well. compatNames := make(map[string][]string) for _, val := range info.Consts { - compat := "LINUX_" + val - compatNames[val] = append(compatNames[val], compat) - info.Consts = append(info.Consts, compat) + const SYS = "SYS_" + if strings.HasPrefix(val, SYS) { + for _, prefix := range []string{"_", "__", "___"} { + compat := SYS + prefix + val[len(SYS):] + "50" + compatNames[val] = append(compatNames[val], compat) + info.Consts = append(info.Consts, compat) + } + } else { + compat := "LINUX_" + val + compatNames[val] = append(compatNames[val], compat) + info.Consts = append(info.Consts, compat) + } } res, undeclared, err := extract(info, "gcc", args, "#include <sys/syscall.h>") for orig, compats := range compatNames { |
