diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-05-01 17:19:27 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-05-02 12:16:06 +0200 |
| commit | 58da4c35b15200b7279f18ea15bc8644618aae78 (patch) | |
| tree | 412d59572c980c4eb582d6d0e187eb6ec32345c9 /pkg/host/syscalls_linux.go | |
| parent | bc734e7ada413654f1b7d948b2a857260a52dd9c (diff) | |
prog: introduce Field type
Remvoe FieldName from Type and add a separate Field type
that holds field name. Use Field for struct fields, union options
and syscalls arguments, only these really have names.
Reduces size of sys/linux/gen/amd64.go from 5665583 to 5201321 (-8.2%).
Allows to not create new type for squashed any pointer.
But main advantages will follow, e.g. removing StructDesc,
using TypeRef in Arg, etc.
Update #1580
Diffstat (limited to 'pkg/host/syscalls_linux.go')
| -rw-r--r-- | pkg/host/syscalls_linux.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/pkg/host/syscalls_linux.go b/pkg/host/syscalls_linux.go index 184bf6410..17ea17dd4 100644 --- a/pkg/host/syscalls_linux.go +++ b/pkg/host/syscalls_linux.go @@ -166,11 +166,11 @@ var ( func isSupportedSyzkall(sandbox string, c *prog.Syscall) (bool, string) { switch c.CallName { case "syz_open_dev": - if _, ok := c.Args[0].(*prog.ConstType); ok { + if _, ok := c.Args[0].Type.(*prog.ConstType); ok { // This is for syz_open_dev$char/block. return true, "" } - fname, ok := extractStringConst(c.Args[0]) + fname, ok := extractStringConst(c.Args[0].Type) if !ok { panic("first open arg is not a pointer to string const") } @@ -249,7 +249,7 @@ func isSupportedSyzkall(sandbox string, c *prog.Syscall) (bool, string) { if ok, reason := onlySandboxNone(sandbox); !ok { return ok, reason } - fstype, ok := extractStringConst(c.Args[0]) + fstype, ok := extractStringConst(c.Args[0].Type) if !ok { panic("syz_mount_image arg is not string") } @@ -306,7 +306,7 @@ func onlySandboxNoneOrNamespace(sandbox string) (bool, string) { } func isSupportedSocket(c *prog.Syscall) (bool, string) { - af, ok := c.Args[0].(*prog.ConstType) + af, ok := c.Args[0].Type.(*prog.ConstType) if !ok { panic("socket family is not const") } @@ -320,14 +320,14 @@ func isSupportedSocket(c *prog.Syscall) (bool, string) { if err == syscall.EAFNOSUPPORT { return false, "socket family is not supported (EAFNOSUPPORT)" } - proto, ok := c.Args[2].(*prog.ConstType) + proto, ok := c.Args[2].Type.(*prog.ConstType) if !ok { return true, "" } var typ uint64 - if arg, ok := c.Args[1].(*prog.ConstType); ok { + if arg, ok := c.Args[1].Type.(*prog.ConstType); ok { typ = arg.Val - } else if arg, ok := c.Args[1].(*prog.FlagsType); ok { + } else if arg, ok := c.Args[1].Type.(*prog.FlagsType); ok { typ = arg.Vals[0] } else { return true, "" @@ -344,7 +344,7 @@ func isSupportedOpenAt(c *prog.Syscall) (bool, string) { var fd int var err error - fname, ok := extractStringConst(c.Args[1]) + fname, ok := extractStringConst(c.Args[1].Type) if !ok || len(fname) == 0 || fname[0] != '/' { return true, "" } @@ -352,7 +352,7 @@ func isSupportedOpenAt(c *prog.Syscall) (bool, string) { modes := []int{syscall.O_RDONLY, syscall.O_WRONLY, syscall.O_RDWR} // Attempt to extract flags from the syscall description - if mode, ok := c.Args[2].(*prog.ConstType); ok { + if mode, ok := c.Args[2].Type.(*prog.ConstType); ok { modes = []int{int(mode.Val)} } @@ -370,7 +370,7 @@ func isSupportedOpenAt(c *prog.Syscall) (bool, string) { } func isSupportedMount(c *prog.Syscall, sandbox string) (bool, string) { - fstype, ok := extractStringConst(c.Args[2]) + fstype, ok := extractStringConst(c.Args[2].Type) if !ok { panic(fmt.Sprintf("%v: filesystem is not string const", c.Name)) } |
