From 3fddc7194573e00eabde07dbb8ff17b025eb5c75 Mon Sep 17 00:00:00 2001 From: Hrutvik Kanabar Date: Tue, 20 Sep 2022 14:43:25 +0000 Subject: pkg/mgrconfig, prog, syz-fuzzer: manager-configurable syscall mutation Allow manager configuration to specify that certain syscalls should not be mutated. This is expected to be useful when mutating certain syscalls is unlikely to produce interesting executions. For example, mutating a `syz_mount_image` call will likely produce a corrupt image. Some implementation details: - Add a `no_mutate_syscalls` manager config entry, with the same format as `enable_syscalls`. Ensure this is parsed and stored in the config as a set of syscall IDs. - Send this set to fuzzers when they connect to their managers via RPC. Ensure each fuzzer stores a copy of the set. - When mutating arguments of a syscall, check first whether it has been specified as non-mutatable. - For all mutations not managed by a `syz-manager`, retain previous behaviour by ensuring that no syscalls are considered non-mutable. --- pkg/mgrconfig/config.go | 2 ++ pkg/mgrconfig/load.go | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'pkg/mgrconfig') diff --git a/pkg/mgrconfig/config.go b/pkg/mgrconfig/config.go index 9073c482c..46270ab0c 100644 --- a/pkg/mgrconfig/config.go +++ b/pkg/mgrconfig/config.go @@ -166,6 +166,8 @@ type Config struct { EnabledSyscalls []string `json:"enable_syscalls,omitempty"` // List of system calls that should be treated as disabled (optional). DisabledSyscalls []string `json:"disable_syscalls,omitempty"` + // List of syscalls that should not be mutated by the fuzzer (optional). + NoMutateSyscalls []string `json:"no_mutate_syscalls,omitempty"` // List of regexps for known bugs. // Don't save reports matching these regexps, but reboot VM after them, // matched against whole report output. diff --git a/pkg/mgrconfig/load.go b/pkg/mgrconfig/load.go index 2b49d0cbd..f1063ed17 100644 --- a/pkg/mgrconfig/load.go +++ b/pkg/mgrconfig/load.go @@ -34,8 +34,9 @@ type Derived struct { ExecprogBin string ExecutorBin string - Syscalls []int - Timeouts targets.Timeouts + Syscalls []int + NoMutateCalls map[int]bool // Set of IDs of syscalls which should not be mutated. + Timeouts targets.Timeouts } func LoadData(data []byte) (*Config, error) { @@ -177,6 +178,10 @@ func Complete(cfg *Config) error { if err != nil { return err } + cfg.NoMutateCalls, err = ParseNoMutateSyscalls(cfg.Target, cfg.NoMutateSyscalls) + if err != nil { + return err + } cfg.initTimeouts() return nil } @@ -329,6 +334,25 @@ func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) ([]in return arr, nil } +func ParseNoMutateSyscalls(target *prog.Target, syscalls []string) (map[int]bool, error) { + var result = make(map[int]bool) + + for _, c := range syscalls { + n := 0 + for _, call := range target.Syscalls { + if MatchSyscall(call.Name, c) { + result[call.ID] = true + n++ + } + } + if n == 0 { + return nil, fmt.Errorf("unknown no_mutate syscall: %v", c) + } + } + + return result, nil +} + func MatchSyscall(name, pattern string) bool { if pattern == name || strings.HasPrefix(name, pattern+"$") { return true -- cgit mrf-deployment