diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-03-14 16:42:00 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-03-17 21:19:13 +0100 |
| commit | 80d43738f1e4c648ccfc4599e17dc8ba455fe1ea (patch) | |
| tree | a2adb84b67e9d760a35fee40ddf06d271f70bab1 /prog/target.go | |
| parent | a2f9a446496d23c4bf6db95e0d4337583595c78c (diff) | |
prog: rename target.SanitizeCall to Neutralize
We will need a wrapper for target.SanitizeCall that will do more
than just calling the target-provided function. To avoid confusion
and potential mistakes, give the target function and prog function
different names. Prog package will continue to call this "sanitize",
which will include target's "neutralize" + more.
Also refactor API a bit: we need a helper function that sanitizes
the whole program because that's needed most of the time.
Fixes #477
Fixes #502
Diffstat (limited to 'prog/target.go')
| -rw-r--r-- | prog/target.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/prog/target.go b/prog/target.go index 69398a54d..b19645ea2 100644 --- a/prog/target.go +++ b/prog/target.go @@ -28,8 +28,9 @@ type Target struct { // MakeMmap creates call that maps [addr, addr+size) memory range. MakeMmap func(addr, size uint64) *Call - // SanitizeCall neutralizes harmful calls. - SanitizeCall func(c *Call) + // Neutralize neutralizes harmful calls by transforming them into non-harmful ones + // (e.g. an ioctl that turns off console output is turned into ioctl that turns on output). + Neutralize func(c *Call) // AnnotateCall annotates a syscall invocation in C reproducers. // The returned string will be placed inside a comment except for the @@ -113,7 +114,7 @@ func AllTargets() []*Target { } func (target *Target) lazyInit() { - target.SanitizeCall = func(c *Call) {} + target.Neutralize = func(c *Call) {} target.AnnotateCall = func(c ExecCall) string { return "" } target.initTarget() target.initArch(target) @@ -165,6 +166,11 @@ func (target *Target) GetConst(name string) uint64 { return v } +func (target *Target) sanitize(c *Call, fix bool) error { + target.Neutralize(c) + return nil +} + func RestoreLinks(syscalls []*Syscall, resources []*ResourceDesc, structs []*KeyedStruct) { restoreLinks(syscalls, resources, structs) } @@ -277,7 +283,7 @@ func MakeProgGen(target *Target) *Builder { func (pg *Builder) Append(c *Call) error { pg.target.assignSizesCall(c) - pg.target.SanitizeCall(c) + pg.target.sanitize(c, true) pg.p.Calls = append(pg.p.Calls, c) return nil } |
