From e8dd2c6713522707b3b89884eb95601cdf9bc9be Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 30 Aug 2018 14:17:47 -0700 Subject: 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). --- prog/encoding.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'prog/encoding.go') diff --git a/prog/encoding.go b/prog/encoding.go index 92e2c47f0..c968fa0b7 100644 --- a/prog/encoding.go +++ b/prog/encoding.go @@ -85,8 +85,8 @@ func (a *ConstArg) serialize(ctx *serializer) { } func (a *PointerArg) serialize(ctx *serializer) { - if a.IsNull() { - ctx.printf("0x0") + if a.IsSpecial() { + ctx.printf("0x%x", a.Address) return } target := ctx.target @@ -345,10 +345,8 @@ func (target *Target) parseArgInt(typ Type, p *parser) (Arg, error) { case *ResourceType: return MakeResultArg(typ, nil, v), nil case *PtrType, *VmaType: - if typ.Optional() { - return MakeNullPointerArg(typ), nil - } - return typ.makeDefaultArg(), nil + index := -v % uint64(len(target.SpecialPointers)) + return MakeSpecialPointerArg(typ, index), nil default: eatExcessive(p, true) return typ.makeDefaultArg(), nil -- cgit mrf-deployment