aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-08-13 18:15:38 -0700
committerDmitry Vyukov <dvyukov@google.com>2016-08-13 18:15:38 -0700
commit0bdfe393727091fdf65d49e6802f618e370e4f85 (patch)
tree0cefa15fcebdd83f5642666f91b335bb02d5a9fc
parent08e664c0440d61fea5b619ae5210f1aeb1551d55 (diff)
host: detect at least some unsupported syscalls if kallsyms is not available
We know how to detect availability of at least some syscalls without kallsyms. Do it.
-rw-r--r--host/host.go20
1 files changed, 10 insertions, 10 deletions
diff --git a/host/host.go b/host/host.go
index 86357e90f..21e54eba3 100644
--- a/host/host.go
+++ b/host/host.go
@@ -26,10 +26,7 @@ func DetectSupportedSyscalls() (map[*sys.Call]bool, error) {
// 3. Check sys_syscallname in /proc/kallsyms.
// Requires CONFIG_KALLSYMS. Seems to be the most reliable. That's what we use here.
- kallsyms, err := ioutil.ReadFile("/proc/kallsyms")
- if err != nil {
- return nil, err
- }
+ kallsyms, _ := ioutil.ReadFile("/proc/kallsyms")
supported := make(map[*sys.Call]bool)
for _, c := range sys.Calls {
if isSupported(kallsyms, c) {
@@ -44,18 +41,21 @@ func isSupported(kallsyms []byte, c *sys.Call) bool {
return false // don't even have a syscall number
}
if strings.HasPrefix(c.CallName, "syz_") {
- return isSupportedSyzkall(kallsyms, c)
+ return isSupportedSyzkall(c)
}
if strings.HasPrefix(c.Name, "socket$") {
- return isSupportedSocket(kallsyms, c)
+ return isSupportedSocket(c)
}
if strings.HasPrefix(c.Name, "open$") {
- return isSupportedOpen(kallsyms, c)
+ return isSupportedOpen(c)
+ }
+ if len(kallsyms) == 0 {
+ return true
}
return bytes.Index(kallsyms, []byte(" T sys_"+c.CallName+"\n")) != -1
}
-func isSupportedSyzkall(kallsyms []byte, c *sys.Call) bool {
+func isSupportedSyzkall(c *sys.Call) bool {
switch c.CallName {
case "syz_open_dev":
ptr, ok := c.Args[0].(sys.PtrType)
@@ -96,7 +96,7 @@ func isSupportedSyzkall(kallsyms []byte, c *sys.Call) bool {
}
}
-func isSupportedSocket(kallsyms []byte, c *sys.Call) bool {
+func isSupportedSocket(c *sys.Call) bool {
af, ok := c.Args[0].(sys.ConstType)
if !ok {
println(c.Name)
@@ -109,7 +109,7 @@ func isSupportedSocket(kallsyms []byte, c *sys.Call) bool {
return err != syscall.ENOSYS && err != syscall.EAFNOSUPPORT
}
-func isSupportedOpen(kallsyms []byte, c *sys.Call) bool {
+func isSupportedOpen(c *sys.Call) bool {
ptr, ok := c.Args[0].(sys.PtrType)
if !ok {
panic("first open arg is not a pointer")