aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-01-01 11:23:45 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-01-06 17:40:49 +0100
commita8927abe6c1b5b5e11339ee5958ad2f365ad3067 (patch)
treee0d08c511a6ce206089e31d40281427d5f58d0b2 /prog
parent8a67aa70b05cbdf2dd5702f4c3ba302f2feba0cf (diff)
prog: support opt for proc types
Diffstat (limited to 'prog')
-rw-r--r--prog/encodingexec_test.go17
-rw-r--r--prog/mutation_test.go6
-rw-r--r--prog/prog.go3
-rw-r--r--prog/types.go5
-rw-r--r--prog/validation.go2
5 files changed, 32 insertions, 1 deletions
diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go
index 5c2c18534..06265fa76 100644
--- a/prog/encodingexec_test.go
+++ b/prog/encodingexec_test.go
@@ -364,6 +364,23 @@ func TestSerializeForExec(t *testing.T) {
},
nil,
},
+ {
+ "syz_test$opt3(0x0)",
+ []uint64{
+ callID("syz_test$opt3"), ExecNoCopyout, 1, execArgConst, 8 | 4<<32, 0x64,
+ execInstrEOF,
+ },
+ nil,
+ },
+ {
+ // Special value that translates to 0 for all procs.
+ "syz_test$opt3(0xffffffffffffffff)",
+ []uint64{
+ callID("syz_test$opt3"), ExecNoCopyout, 1, execArgConst, 8, 0,
+ execInstrEOF,
+ },
+ nil,
+ },
}
buf := make([]byte, ExecBufferSize)
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 21f0261dd..97490a078 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -143,6 +143,12 @@ mutate7(&(0x7f0000000000)='123', 0x3)
`, `
mutate7(&(0x7f0000000000)='123', 0x2)
`},
+ // Mutate proc to the special value.
+ {`
+mutate8(0x2)
+`, `
+mutate8(0xffffffffffffffff)
+`},
}
for ti, test := range tests {
test := test
diff --git a/prog/prog.go b/prog/prog.go
index 4a612d9ba..a323bafa3 100644
--- a/prog/prog.go
+++ b/prog/prog.go
@@ -81,6 +81,9 @@ func (arg *ConstArg) Value() (uint64, uint64, bool) {
t := typ.Desc.Type.(*IntType)
return arg.Val, 0, t.BigEndian
case *ProcType:
+ if arg.Val == typ.Default() {
+ return 0, 0, false
+ }
return typ.ValuesStart + arg.Val, typ.ValuesPerProc, typ.BigEndian
default:
panic(fmt.Sprintf("unknown ConstArg type %#v", typ))
diff --git a/prog/types.go b/prog/types.go
index 16e8421f1..5ed3a41ba 100644
--- a/prog/types.go
+++ b/prog/types.go
@@ -173,6 +173,11 @@ type ProcType struct {
ValuesPerProc uint64
}
+func (t *ProcType) Default() uint64 {
+ // Special value denoting 0 for all procs.
+ return 0xffffffffffffffff
+}
+
type CsumKind int
const (
diff --git a/prog/validation.go b/prog/validation.go
index 288a8172b..2b0fb984c 100644
--- a/prog/validation.go
+++ b/prog/validation.go
@@ -112,7 +112,7 @@ func (c *Call) validate(ctx *validCtx) error {
case *ProcType:
switch a := arg.(type) {
case *ConstArg:
- if a.Val >= typ1.ValuesPerProc {
+ if a.Val >= typ1.ValuesPerProc && a.Val != typ1.Default() {
return fmt.Errorf("syscall %v: per proc arg '%v' has bad value '%v'", c.Meta.Name, a.Type().Name(), a.Val)
}
default: