From 75a7c5e2d1f09a4a58e7e1f1f4ef0b0f55a33413 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 19 Feb 2018 19:35:04 +0100 Subject: prog: rework address allocation 1. mmap all memory always, without explicit mmap calls in the program. This makes lots of things much easier and removes lots of code. Makes mmap not a special syscall and allows to fuzz without mmap enabled. 2. Change address assignment algorithm. Current algorithm allocates unmapped addresses too frequently and allows collisions between arguments of a single syscall. The new algorithm analyzes actual allocations in the program and places new arguments at unused locations. --- prog/mutation_test.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'prog/mutation_test.go') diff --git a/prog/mutation_test.go b/prog/mutation_test.go index 5c5ac232a..2267dd254 100644 --- a/prog/mutation_test.go +++ b/prog/mutation_test.go @@ -135,7 +135,6 @@ mutate5(&(0x7f0000001000)="2e2f66696c653100", 0x22c0) {` mutate3(&(0x7f0000000000)=[0x1, 0x1], 0x2) `, ` -mmap(&(0x7f0000000000/0x1000)=nil, 0x1000) mutate3(&(0x7f0000000000)=[0x1, 0x1, 0x1], 0x3) `}, // Mutate size from it's natural value. @@ -206,3 +205,22 @@ func BenchmarkMutate(b *testing.B) { } }) } + +func BenchmarkGenerate(b *testing.B) { + olddebug := debug + debug = false + defer func() { debug = olddebug }() + target, err := GetTarget("linux", "amd64") + if err != nil { + b.Fatal(err) + } + prios := target.CalculatePriorities(nil) + ct := target.BuildChoiceTable(prios, nil) + const progLen = 30 + b.RunParallel(func(pb *testing.PB) { + rs := rand.NewSource(0) + for pb.Next() { + target.Generate(rs, progLen, ct) + } + }) +} -- cgit mrf-deployment