diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-06-18 19:45:45 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-06-18 19:45:45 +0200 |
| commit | 7bd97c6ff6472db1e2ad9f279fe517cd7b5daee2 (patch) | |
| tree | b641c14bab0b0d5bd4a9477fcdeb33fcb5fecc87 /pkg/host | |
| parent | b7d00d1e1453e66126fc5feda11aac7033b337c4 (diff) | |
pkg/host: better detection of supported sockets
Check socketpair.
Check non-constant socket types.
Diffstat (limited to 'pkg/host')
| -rw-r--r-- | pkg/host/host_linux.go | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/pkg/host/host_linux.go b/pkg/host/host_linux.go index 252af983c..dff8bd88d 100644 --- a/pkg/host/host_linux.go +++ b/pkg/host/host_linux.go @@ -37,7 +37,8 @@ func isSupported(c *prog.Syscall, sandbox string) (bool, string) { if strings.HasPrefix(c.CallName, "syz_") { return isSupportedSyzkall(sandbox, c) } - if strings.HasPrefix(c.Name, "socket$") { + if strings.HasPrefix(c.Name, "socket$") || + strings.HasPrefix(c.Name, "socketpair$") { return isSupportedSocket(c) } if strings.HasPrefix(c.Name, "openat$") { @@ -181,7 +182,24 @@ func isSupportedSocket(c *prog.Syscall) (bool, string) { if err == syscall.EAFNOSUPPORT { return false, "socket family is not supported (EAFNOSUPPORT)" } - return true, "" + proto, ok := c.Args[2].(*prog.ConstType) + if !ok { + return true, "" + } + var typ uint64 + if arg, ok := c.Args[1].(*prog.ConstType); ok { + typ = arg.Val + } else if arg, ok := c.Args[1].(*prog.FlagsType); ok { + typ = arg.Vals[0] + } else { + return true, "" + } + fd, err = syscall.Socket(int(af.Val), int(typ), int(proto.Val)) + if fd != -1 { + syscall.Close(fd) + return true, "" + } + return false, err.Error() } func isSupportedOpenAt(c *prog.Syscall) (bool, string) { |
