Skip to content
Permalink
Browse files

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.
  • Loading branch information
dvyukov committed Jul 12, 2018
1 parent 3986ce9 commit 06c33b3af0ff4072fb002879f83077c9d162a224
Showing with 9 additions and 4 deletions.
  1. +1 −0 prog/hints.go
  2. +3 −3 prog/minimization_test.go
  3. +5 −1 prog/validation.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))
@@ -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,
@@ -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 {

0 comments on commit 06c33b3

Please sign in to comment.
You can’t perform that action at this time.