aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/mgrconfig/load.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/mgrconfig/load.go')
-rw-r--r--pkg/mgrconfig/load.go28
1 files changed, 26 insertions, 2 deletions
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