From 9ef240be5fd0feed4ba63edfba3cbaa94837d01d Mon Sep 17 00:00:00 2001 From: Anton Lindqvist Date: Wed, 4 Mar 2020 16:42:55 +0100 Subject: sys/syz-extract: fix handling of odd prefixed syscalls on OpenBSD This makes syz-extract work again on OpenBSD. --- sys/syz-extract/openbsd.go | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/sys/syz-extract/openbsd.go b/sys/syz-extract/openbsd.go index 715131f28..37b29bdd7 100644 --- a/sys/syz-extract/openbsd.go +++ b/sys/syz-extract/openbsd.go @@ -57,21 +57,26 @@ func (*openbsd) processFile(arch *Arch, info *compiler.ConstInfo) (map[string]ui args = append(args, "-I"+dir) } } - // Syscall consts on openbsd have weird prefixes sometimes, - // try to extract consts with these prefixes as well. + // Some syscalls on OpenBSD are prefixed with `SYS___' as opposed of the + // more common `SYS_' prefix. + syscallsQuirks := map[string]bool{ + "SYS_get_tcb": true, + "SYS_getcwd": true, + "SYS_realpath": true, + "SYS_semctl": true, + "SYS_set_tcb": true, + "SYS_syscall": true, + "SYS_tfork": true, + "SYS_threxit": true, + "SYS_thrsigdivert": true, + "SYS_thrsleep": true, + "SYS_thrwakeup": true, + "SYS_tmpfd": true, + } compatNames := make(map[string][]string) for _, val := range info.Consts { - const SYS = "SYS_" - if strings.HasPrefix(val, SYS) { - for _, prefix := range []string{"_", "__", "___"} { - for _, suffix := range []string{"30", "50"} { - compat := SYS + prefix + val[len(SYS):] + suffix - compatNames[val] = append(compatNames[val], compat) - info.Consts = append(info.Consts, compat) - } - } - } else { - compat := "LINUX_" + val + if _, ok := syscallsQuirks[val]; ok { + compat := "SYS___" + val[len("SYS_"):] compatNames[val] = append(compatNames[val], compat) info.Consts = append(info.Consts, compat) } -- cgit mrf-deployment