aboutsummaryrefslogtreecommitdiffstats
path: root/prog/target.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-08-30 14:17:47 -0700
committerDmitry Vyukov <dvyukov@google.com>2018-08-30 21:45:03 -0700
commite8dd2c6713522707b3b89884eb95601cdf9bc9be (patch)
tree9df12a938af90c06794ec9f60920d59330766ed1 /prog/target.go
parent6ba5fe3e62880ddf8aeec68ab44eabaa8bc148b8 (diff)
prog: add concept of "special pointers"
Currently we only generate either valid user-space pointers or NULL. Extend NULL to a set of special pointers that we will use in programs. All targets now contain 3 special values: - NULL - 0xfffffffffffffff (invalid kernel pointer) - 0x999999999999999 (non-canonical address) Each target can add additional special pointers on top of this. Also generate NULL/special pointers for non-opt ptr's. This restriction was always too restrictive. We may want to generate them with very low probability, but we do want to generate them. Also change pointers to NULL/special during mutation (but still not in the opposite direction).
Diffstat (limited to 'prog/target.go')
-rw-r--r--prog/target.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/prog/target.go b/prog/target.go
index 80a2665ae..631b756e8 100644
--- a/prog/target.go
+++ b/prog/target.go
@@ -44,6 +44,9 @@ type Target struct {
// Used as fallback when string type does not have own dictionary.
StringDictionary []string
+ // Additional special invalid pointer values besides NULL to use.
+ SpecialPointers []uint64
+
// Filled by prog package:
init sync.Once
initArch func(target *Target)
@@ -55,6 +58,8 @@ type Target struct {
any anyTypes
}
+const maxSpecialPointers = 16
+
var targets = make(map[string]*Target)
func RegisterTarget(target *Target, initArch func(target *Target)) {
@@ -101,6 +106,15 @@ func (target *Target) lazyInit() {
target.initTarget()
target.initArch(target)
target.ConstMap = nil // currently used only by initArch
+ // Give these 2 known addresses fixed positions and prepend target-specific ones at the end.
+ target.SpecialPointers = append([]uint64{
+ 0x0000000000000000, // NULL pointer (keep this first because code uses special index=0 as NULL)
+ 0xffffffffffffffff, // unmapped kernel address (keep second because serialized value will match actual pointer value)
+ 0x9999999999999999, // non-canonical address
+ }, target.SpecialPointers...)
+ if len(target.SpecialPointers) > maxSpecialPointers {
+ panic("too many special pointers")
+ }
}
func (target *Target) initTarget() {