diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-07-12 12:40:30 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-07-12 12:40:30 +0200 |
| commit | 06c33b3af0ff4072fb002879f83077c9d162a224 (patch) | |
| tree | 50ff54e3ee901980be2cf41914a7d95a7dc26458 | |
| parent | 3986ce95fde3d4b5bccef19b537da090021046fc (diff) | |
prog: sanitize calls after hints mutation
Hints mutation could produce unsanitized calls.
Sanitize calls after hints mutation.
Also sanitize on load (in validate), because bad programs
can already be in corpuses. And it's just the right thing
to do because sanitization rules can change over time.
| -rw-r--r-- | prog/hints.go | 1 | ||||
| -rw-r--r-- | prog/minimization_test.go | 6 | ||||
| -rw-r--r-- | prog/validation.go | 6 |
3 files changed, 9 insertions, 4 deletions
diff --git a/prog/hints.go b/prog/hints.go index 778655105..5250476e4 100644 --- a/prog/hints.go +++ b/prog/hints.go @@ -67,6 +67,7 @@ func (p *Prog) MutateWithHints(callIndex int, comps CompMap, exec func(p *Prog)) p = p.Clone() c := p.Calls[callIndex] execValidate := func() { + p.Target.SanitizeCall(c) if debug { if err := p.validate(); err != nil { panic(fmt.Sprintf("invalid hints candidate: %v", err)) diff --git a/prog/minimization_test.go b/prog/minimization_test.go index 9cedb940f..d41663e70 100644 --- a/prog/minimization_test.go +++ b/prog/minimization_test.go @@ -46,7 +46,7 @@ func TestMinimize(t *testing.T) { // Aim at removal of sched_yield. return len(p.Calls) == 2 && p.Calls[0].Meta.Name == "mmap" && p.Calls[1].Meta.Name == "pipe2" }, - "mmap(&(0x7f0000000000/0x1000)=nil, 0x1000, 0x0, 0x0, 0xffffffffffffffff, 0x0)\n" + + "mmap(&(0x7f0000000000/0x1000)=nil, 0x1000, 0x0, 0x10, 0xffffffffffffffff, 0x0)\n" + "pipe2(&(0x7f0000000000), 0x0)\n", 1, }, @@ -79,7 +79,7 @@ func TestMinimize(t *testing.T) { func(p *Prog, callIndex int) bool { return p.String() == "mmap-write-sched_yield" }, - "mmap(&(0x7f0000000000/0x1000)=nil, 0x1000, 0x0, 0x0, 0xffffffffffffffff, 0x0)\n" + + "mmap(&(0x7f0000000000/0x1000)=nil, 0x1000, 0x0, 0x10, 0xffffffffffffffff, 0x0)\n" + "write(0xffffffffffffffff, &(0x7f0000000000), 0x0)\n" + "sched_yield()\n", 2, @@ -94,7 +94,7 @@ func TestMinimize(t *testing.T) { func(p *Prog, callIndex int) bool { return p.String() == "mmap-write-sched_yield" }, - "mmap(&(0x7f0000000000/0x1000)=nil, 0x1000, 0x0, 0x0, 0xffffffffffffffff, 0x0)\n" + + "mmap(&(0x7f0000000000/0x1000)=nil, 0x1000, 0x0, 0x10, 0xffffffffffffffff, 0x0)\n" + "write(0xffffffffffffffff, &(0x7f0000000000), 0x0)\n" + "sched_yield()\n", -1, diff --git a/prog/validation.go b/prog/validation.go index 148640650..133da3adb 100644 --- a/prog/validation.go +++ b/prog/validation.go @@ -48,7 +48,11 @@ func (ctx *validCtx) validateCall(c *Call) error { return err } } - return ctx.validateRet(c) + if err := ctx.validateRet(c); err != nil { + return err + } + ctx.target.SanitizeCall(c) + return nil } func (ctx *validCtx) validateRet(c *Call) error { |
