diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2018-02-19 19:35:04 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-02-19 21:48:20 +0100 |
| commit | 75a7c5e2d1f09a4a58e7e1f1f4ef0b0f55a33413 (patch) | |
| tree | d44c2457c44b53192005f0b89cd6633a2a2b0ff9 /sys/syz-sysgen | |
| parent | 90fd6503136121e9494761a460898e83bc0b6b3e (diff) | |
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.
Diffstat (limited to 'sys/syz-sysgen')
| -rw-r--r-- | sys/syz-sysgen/sysgen.go | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/sys/syz-sysgen/sysgen.go b/sys/syz-sysgen/sysgen.go index aafc44feb..d91970f59 100644 --- a/sys/syz-sysgen/sysgen.go +++ b/sys/syz-sysgen/sysgen.go @@ -135,10 +135,12 @@ func generate(target *targets.Target, prg *compiler.Prog, consts map[string]uint fmt.Fprintf(out, "import . \"github.com/google/syzkaller/prog\"\n\n") fmt.Fprintf(out, "func init() {\n") - fmt.Fprintf(out, "\tRegisterTarget(&Target{OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v,"+ - "Syscalls: syscalls_%v, Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}, "+ + fmt.Fprintf(out, "\tRegisterTarget(&Target{OS: %q, Arch: %q, Revision: revision_%v, PtrSize: %v, "+ + "PageSize: %v, NumPages: %v, DataOffset: %v, Syscalls: syscalls_%v, "+ + "Resources: resources_%v, Structs: structDescs_%v, Consts: consts_%v}, "+ "initTarget)\n", target.OS, target.Arch, target.Arch, target.PtrSize, + target.PageSize, target.NumPages, target.DataOffset, target.Arch, target.Arch, target.Arch, target.Arch) fmt.Fprintf(out, "}\n\n") @@ -174,15 +176,21 @@ func generateExecutorSyscalls(target *targets.Target, syscalls []*prog.Syscall, NeedCall bool } type ArchData struct { - Revision string - GOARCH string - CARCH []string - Calls []SyscallData + Revision string + GOARCH string + CARCH []string + PageSize uint64 + NumPages uint64 + DataOffset uint64 + Calls []SyscallData } data := ArchData{ - Revision: rev, - GOARCH: target.Arch, - CARCH: target.CArch, + Revision: rev, + GOARCH: target.Arch, + CARCH: target.CArch, + PageSize: target.PageSize, + NumPages: target.NumPages, + DataOffset: target.DataOffset, } for _, c := range syscalls { data.Calls = append(data.Calls, SyscallData{ @@ -247,6 +255,9 @@ var archTempl = template.Must(template.New("").Parse(` #if {{range $cdef := $.CARCH}}defined({{$cdef}}) || {{end}}0 #define GOARCH "{{.GOARCH}}" #define SYZ_REVISION "{{.Revision}}" +#define SYZ_PAGE_SIZE {{.PageSize}} +#define SYZ_NUM_PAGES {{.NumPages}} +#define SYZ_DATA_OFFSET {{.DataOffset}} unsigned syscall_count = {{len $.Calls}}; call_t syscalls[] = { {{range $c := $.Calls}} {"{{$c.Name}}", {{$c.NR}}{{if $c.NeedCall}}, (syscall_t){{$c.CallName}}{{end}}}, |
