diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-08-27 19:55:14 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-08-27 20:19:41 +0200 |
| commit | 4074aed7c0c28afc7d4a3522045196c3f39b5208 (patch) | |
| tree | 8d2c2ce5f6767f8f4355e37e262f85223ee362e3 /sys | |
| parent | 58579664687b203ff34fad8aa02bf470ef0bc981 (diff) | |
pkg/compiler: more static error checking
Update #217
Diffstat (limited to 'sys')
| -rw-r--r-- | sys/sys.txt | 7 | ||||
| -rw-r--r-- | sys/syz-extract/extract.go | 12 | ||||
| -rw-r--r-- | sys/syz-sysgen/sysgen.go | 17 |
3 files changed, 9 insertions, 27 deletions
diff --git a/sys/sys.txt b/sys/sys.txt index bbf717578..9061ece4c 100644 --- a/sys/sys.txt +++ b/sys/sys.txt @@ -21,7 +21,6 @@ include <linux/timerfd.h> include <linux/personality.h> include <linux/wait.h> include <linux/user.h> -include <linux/socket.h> include <linux/un.h> include <linux/ioctl.h> include <linux/fadvise.h> @@ -31,7 +30,6 @@ include <linux/aio_abi.h> include <linux/kexec.h> include <linux/seccomp.h> include <linux/elf.h> -include <linux/fs.h> include <linux/fiemap.h> include <linux/kd.h> include <linux/vt.h> @@ -44,9 +42,7 @@ include <linux/termios.h> include <linux/fcntl.h> include <linux/sched.h> include <linux/mqueue.h> -include <linux/time.h> include <linux/mempolicy.h> -include <linux/mman.h> include <linux/in.h> include <linux/ip.h> include <linux/tcp.h> @@ -54,8 +50,6 @@ include <linux/udp.h> include <linux/kcmp.h> include <linux/syslog.h> include <linux/userfaultfd.h> -include <linux/aio_abi.h> -include <linux/personality.h> include <linux/memfd.h> include <uapi/linux/module.h> include <asm/prctl.h> @@ -973,7 +967,6 @@ fanotify_events = O_RDONLY, O_WRONLY, O_RDWR, O_LARGEFILE, O_CLOEXEC, O_APPEND, fanotify_mark = FAN_MARK_ADD, FAN_MARK_REMOVE, FAN_MARK_FLUSH, FAN_MARK_DONT_FOLLOW, FAN_MARK_ONLYDIR, FAN_MARK_MOUNT, FAN_MARK_IGNORED_MASK, FAN_MARK_IGNORED_SURV_MODIFY fanotify_mask = FAN_ACCESS, FAN_MODIFY, FAN_CLOSE_WRITE, FAN_CLOSE_NOWRITE, FAN_OPEN, FAN_OPEN_PERM, FAN_ACCESS_PERM, FAN_ONDIR, FAN_EVENT_ON_CHILD faccessat_flags = 0x100, 0x200, 0x400, 0x800, 0x1000 -clone_flags = CLONE_CHILD_CLEARTID, CLONE_CHILD_SETTID, CLONE_FILES, CLONE_FS, CLONE_IO, CLONE_NEWIPC, CLONE_NEWNET, CLONE_NEWNS, CLONE_NEWPID, CLONE_NEWUTS, CLONE_PARENT, CLONE_PARENT_SETTID, CLONE_PTRACE, CLONE_SETTLS, CLONE_SIGHAND, CLONE_SYSVSEM, CLONE_THREAD, CLONE_UNTRACED, CLONE_VFORK, CLONE_VM, CLONE_NEWCGROUP futex_op = FUTEX_WAIT, FUTEX_WAIT_BITSET, FUTEX_WAKE, FUTEX_REQUEUE, FUTEX_CMP_REQUEUE sync_file_flags = SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_AFTER kcmp_flags = KCMP_FILE, KCMP_FILES, KCMP_FS, KCMP_IO, KCMP_SIGHAND, KCMP_SYSVSEM, KCMP_VM diff --git a/sys/syz-extract/extract.go b/sys/syz-extract/extract.go index 7000bdc5f..d2af1db4c 100644 --- a/sys/syz-extract/extract.go +++ b/sys/syz-extract/extract.go @@ -65,7 +65,7 @@ func main() { failf("failed to read input file: %v", err) } - desc := ast.Parse(indata, filepath.Dir(inname), nil) + desc := ast.Parse(indata, filepath.Base(inname), nil) if desc == nil { os.Exit(1) } @@ -79,11 +79,15 @@ func main() { } func compileConsts(arch *Arch, desc *ast.Description) map[string]uint64 { - valArr, includes, incdirs, defines := compiler.ExtractConsts(desc) - if len(valArr) == 0 { + info := compiler.ExtractConsts(desc, nil) + if info == nil { + os.Exit(1) + } + if len(info.Consts) == 0 { return nil } - consts, err := fetchValues(arch.KernelHeaderArch, valArr, append(includes, arch.KernelInclude), incdirs, defines, arch.CFlags) + consts, err := fetchValues(arch.KernelHeaderArch, info.Consts, + append(info.Includes, arch.KernelInclude), info.Incdirs, info.Defines, arch.CFlags) if err != nil { failf("%v", err) } diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index 984a5b4e8..f53f247bc 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -132,8 +132,6 @@ func (a syscallArray) Swap(i, j int) { a[i], a[j] = a[j], a[i] } func astToDesc(top *ast.Description) *Description { // As a temporal measure we just convert the new representation to the old one. - // TODO: check for duplicate defines, structs, resources. - // TODO: check for duplicate syscall argument names. desc := &Description{ Structs: make(map[string]*Struct), Unnamed: make(map[string][]string), @@ -155,7 +153,7 @@ func astToDesc(top *ast.Description) *Description { } desc.Resources[n.Name.Name] = Resource{ Name: n.Name.Name, - Base: n.Base.Name, + Base: n.Base.Ident, Values: vals, } case *ast.Call: @@ -209,19 +207,6 @@ func astToDesc(top *ast.Description) *Description { } } } - if str.IsUnion && len(str.Flds) <= 1 { - failf("union %v has only %v fields, need at least 2", str.Name, len(str.Flds)) - } - fields := make(map[string]bool) - for _, f := range str.Flds { - if f[0] == "parent" { - failf("struct/union %v contains reserved field 'parent'", str.Name) - } - if fields[f[0]] { - failf("duplicate field %v in struct/union %v", f[0], str.Name) - } - fields[f[0]] = true - } desc.Structs[str.Name] = str case *ast.IntFlags: var vals []string |
