aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/host
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2022-01-12 13:54:32 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2022-01-13 17:03:14 +0100
commitf635b41d90ee4c01636d9b7f67091aa2ce2c2f20 (patch)
tree51a479e96f86fa7b3cca4aff90f9067da6182b33 /pkg/host
parent40c93acdacf984554ac152f1b7f06ba400fde8b0 (diff)
all: explicitly list pseudo syscall dependencies
Pseudo syscalls can (and most of the time) do invoke normal system calls. However, when there's a risk that those calls might not be present, syzkaller needs to take preventive actions - prepend the corresponding defines. Otherwise syz-executor or C reproducers might not compile on the host machine. List those dependencies in sys/targets, check them during machine check and add the corresponding defines during C source generation.
Diffstat (limited to 'pkg/host')
-rw-r--r--pkg/host/syscalls_linux.go21
1 files changed, 15 insertions, 6 deletions
diff --git a/pkg/host/syscalls_linux.go b/pkg/host/syscalls_linux.go
index 1d305b4e0..f43f1ada3 100644
--- a/pkg/host/syscalls_linux.go
+++ b/pkg/host/syscalls_linux.go
@@ -71,6 +71,14 @@ func isSupportedSyscall(c *prog.Syscall, target *prog.Target) (bool, string) {
return isSupportedTrial(c)
}
+func isSupportedSyscallName(name string, target *prog.Target) (bool, string) {
+ syscall := target.SyscallMap[name]
+ if syscall == nil {
+ return false, fmt.Sprintf("sys_%v is not present in the target", name)
+ }
+ return isSupportedSyscall(syscall, target)
+}
+
func parseKallsyms(kallsyms []byte, arch string) map[string]bool {
set := make(map[string]bool)
var re *regexp.Regexp
@@ -245,12 +253,7 @@ func isSyzReadPartTableSupported(c *prog.Syscall, target *prog.Target, sandbox s
}
func isSyzIoUringSupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {
- ioUringSyscallName := "io_uring_setup"
- ioUringSyscall := target.SyscallMap[ioUringSyscallName]
- if ioUringSyscall == nil {
- return false, fmt.Sprintf("sys_%v is not present in the target", ioUringSyscallName)
- }
- return isSupportedSyscall(ioUringSyscall, target)
+ return isSupportedSyscallName("io_uring_setup", target)
}
func isSyzMemcpySupported(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {
@@ -316,6 +319,12 @@ var syzkallSupport = map[string]func(*prog.Syscall, *prog.Target, string) (bool,
}
func isSupportedSyzkall(c *prog.Syscall, target *prog.Target, sandbox string) (bool, string) {
+ sysTarget := targets.Get(target.OS, target.Arch)
+ for _, depCall := range sysTarget.PseudoSyscallDeps[c.CallName] {
+ if ok, reason := isSupportedSyscallName(depCall, target); !ok {
+ return ok, reason
+ }
+ }
if isSupported, ok := syzkallSupport[c.CallName]; ok {
return isSupported(c, target, sandbox)
}