aboutsummaryrefslogtreecommitdiffstats
path: root/sys/test
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-02-19 19:35:04 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-02-19 21:48:20 +0100
commit75a7c5e2d1f09a4a58e7e1f1f4ef0b0f55a33413 (patch)
treed44c2457c44b53192005f0b89cd6633a2a2b0ff9 /sys/test
parent90fd6503136121e9494761a460898e83bc0b6b3e (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/test')
-rw-r--r--sys/test/32.go4
-rw-r--r--sys/test/64.go4
-rw-r--r--sys/test/init.go22
3 files changed, 7 insertions, 23 deletions
diff --git a/sys/test/32.go b/sys/test/32.go
index 7eb9ad351..0be1916c6 100644
--- a/sys/test/32.go
+++ b/sys/test/32.go
@@ -4,7 +4,7 @@ package test
import . "github.com/google/syzkaller/prog"
func init() {
- RegisterTarget(&Target{OS: "test", Arch: "32", Revision: revision_32, PtrSize: 4, Syscalls: syscalls_32, Resources: resources_32, Structs: structDescs_32, Consts: consts_32}, initTarget)
+ RegisterTarget(&Target{OS: "test", Arch: "32", Revision: revision_32, PtrSize: 4, PageSize: 8192, NumPages: 2048, DataOffset: 536870912, Syscalls: syscalls_32, Resources: resources_32, Structs: structDescs_32, Consts: consts_32}, initTarget)
}
var resources_32 = []*ResourceDesc{
@@ -695,4 +695,4 @@ var consts_32 = []ConstValue{
{Name: "ONLY_32BITS_CONST", Value: 1},
}
-const revision_32 = "229a33891b79d4c76384836d58be89caaab83684"
+const revision_32 = "6f7cae371c55b5afdfbc7f518e21c58894cfce5b"
diff --git a/sys/test/64.go b/sys/test/64.go
index 943bd9ee0..251f12a5f 100644
--- a/sys/test/64.go
+++ b/sys/test/64.go
@@ -4,7 +4,7 @@ package test
import . "github.com/google/syzkaller/prog"
func init() {
- RegisterTarget(&Target{OS: "test", Arch: "64", Revision: revision_64, PtrSize: 8, Syscalls: syscalls_64, Resources: resources_64, Structs: structDescs_64, Consts: consts_64}, initTarget)
+ RegisterTarget(&Target{OS: "test", Arch: "64", Revision: revision_64, PtrSize: 8, PageSize: 4096, NumPages: 4096, DataOffset: 536870912, Syscalls: syscalls_64, Resources: resources_64, Structs: structDescs_64, Consts: consts_64}, initTarget)
}
var resources_64 = []*ResourceDesc{
@@ -693,4 +693,4 @@ var consts_64 = []ConstValue{
{Name: "IPPROTO_UDP", Value: 17},
}
-const revision_64 = "72bf9b428d7ccdf1adbb2ef093b656ca3564ee14"
+const revision_64 = "e5ba3c9ee8fe997bfacae016e4bbebd8ecb2f573"
diff --git a/sys/test/init.go b/sys/test/init.go
index 860654878..5df5ba0b4 100644
--- a/sys/test/init.go
+++ b/sys/test/init.go
@@ -10,39 +10,23 @@ import (
func initTarget(target *prog.Target) {
arch := &arch{
mmapSyscall: target.SyscallMap["mmap"],
- pageSize: (12 - target.PtrSize) << 10,
}
- target.PageSize = arch.pageSize
- target.DataOffset = 100 << 20
- target.MmapSyscall = arch.mmapSyscall
target.MakeMmap = arch.makeMmap
- target.AnalyzeMmap = arch.analyzeMmap
}
type arch struct {
mmapSyscall *prog.Syscall
- pageSize uint64
}
-func (arch *arch) makeMmap(start, npages uint64) *prog.Call {
+func (arch *arch) makeMmap(addr, size uint64) *prog.Call {
meta := arch.mmapSyscall
return &prog.Call{
Meta: meta,
Args: []prog.Arg{
- prog.MakePointerArg(meta.Args[0], start, 0, npages, nil),
- prog.MakeConstArg(meta.Args[1], npages*arch.pageSize),
+ prog.MakeVmaPointerArg(meta.Args[0], addr, size),
+ prog.MakeConstArg(meta.Args[1], size),
},
Ret: prog.MakeReturnArg(meta.Ret),
}
}
-
-func (arch *arch) analyzeMmap(c *prog.Call) (start, npages uint64, mapped bool) {
- switch c.Meta.Name {
- case "mmap":
- npages = c.Args[1].(*prog.ConstArg).Val / arch.pageSize
- start = c.Args[0].(*prog.PointerArg).PageIndex
- mapped = true
- }
- return
-}