aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-07-26 10:29:11 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-07-26 10:29:36 +0200
commitcf49ed5769e95e2146c56883ebc957b22713381a (patch)
tree573a3997d46332dc2a89fe3f65d7c5606ebf2b15
parent091bb0070faa61066041adf59b088a7a873a480d (diff)
prog: don't minimize ProcType to 0
Default value for ProcType is 0 (same for all PID's). Usually 0 either does not make sense at all or make different PIDs collide (since we use ProcType to separate value ranges for different PIDs). So don't change ProcType to 0 unless the type is explicitly marked as opt (in that case we will also generate 0 anyway).
-rw-r--r--executor/defs.h2
-rw-r--r--executor/syscalls.h1
-rw-r--r--prog/minimization.go8
-rw-r--r--prog/minimization_test.go8
-rw-r--r--sys/test/gen/64.go7
-rw-r--r--sys/test/test.txt4
-rw-r--r--sys/test/test_64.const1
7 files changed, 29 insertions, 2 deletions
diff --git a/executor/defs.h b/executor/defs.h
index dd408b45a..ccbdd75c2 100644
--- a/executor/defs.h
+++ b/executor/defs.h
@@ -175,7 +175,7 @@
#if GOARCH_64
#define GOARCH "64"
-#define SYZ_REVISION "74c87d08a1f72c38c85e889813b60823a1e5755c"
+#define SYZ_REVISION "8c0a50a6c63e5bd297e9f6421864685e1fd7dc96"
#define SYZ_EXECUTOR_USES_FORK_SERVER 0
#define SYZ_EXECUTOR_USES_SHMEM 0
#define SYZ_PAGE_SIZE 4096
diff --git a/executor/syscalls.h b/executor/syscalls.h
index 463ee2919..7d6bbeedd 100644
--- a/executor/syscalls.h
+++ b/executor/syscalls.h
@@ -16275,6 +16275,7 @@ const call_t syscalls[] = {
{"foo$fmt3", 0},
{"foo$fmt4", 0},
{"foo$fmt5", 0},
+ {"minimize$0", 0},
{"mutate0", 0},
{"mutate1", 0},
{"mutate2", 0},
diff --git a/prog/minimization.go b/prog/minimization.go
index 9dad3a494..9a71dd067 100644
--- a/prog/minimization.go
+++ b/prog/minimization.go
@@ -185,6 +185,14 @@ func (typ *FlagsType) minimize(ctx *minimizeArgsCtx, arg Arg, path string) bool
}
func (typ *ProcType) minimize(ctx *minimizeArgsCtx, arg Arg, path string) bool {
+ if !typ.Optional() {
+ // Default value for ProcType is 0 (same for all PID's).
+ // Usually 0 either does not make sense at all or make different PIDs collide
+ // (since we use ProcType to separate value ranges for different PIDs).
+ // So don't change ProcType to 0 unless the type is explicitly marked as opt
+ // (in that case we will also generate 0 anyway).
+ return false
+ }
return minimizeInt(ctx, arg, path)
}
diff --git a/prog/minimization_test.go b/prog/minimization_test.go
index cb651d878..3fde47c77 100644
--- a/prog/minimization_test.go
+++ b/prog/minimization_test.go
@@ -141,6 +141,14 @@ func TestMinimize(t *testing.T) {
"test$res1(r0)\n",
-1,
},
+ {
+ "test", "64",
+ "minimize$0(0x1, 0x1)\n",
+ -1,
+ func(p *Prog, callIndex int) bool { return len(p.Calls) == 1 },
+ "minimize$0(0x1, 0xffffffffffffffff)\n",
+ -1,
+ },
}
t.Parallel()
for ti, test := range tests {
diff --git a/sys/test/gen/64.go b/sys/test/gen/64.go
index 00cba243f..b6f1b0bee 100644
--- a/sys/test/gen/64.go
+++ b/sys/test/gen/64.go
@@ -637,6 +637,10 @@ var syscalls_64 = []*Syscall{
{Name: "foo$fmt5", CallName: "foo", MissingArgs: 1, Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "struct$fmt0"}}},
}},
+ {Name: "minimize$0", CallName: "minimize", Args: []Type{
+ &ProcType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "proc", FldName: "a0", TypeSize: 8}}, ValuesStart: 10, ValuesPerProc: 2},
+ &ProcType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "proc", FldName: "a1", TypeSize: 8, IsOptional: true}}, ValuesStart: 10, ValuesPerProc: 2},
+ }},
{Name: "mutate0", CallName: "mutate0"},
{Name: "mutate1", CallName: "mutate1"},
{Name: "mutate2", CallName: "mutate2"},
@@ -1018,6 +1022,7 @@ var consts_64 = []ConstValue{
{Name: "IPPROTO_UDP", Value: 17},
{Name: "SYS_fallback"},
{Name: "SYS_foo"},
+ {Name: "SYS_minimize"},
{Name: "SYS_mutate0"},
{Name: "SYS_mutate1"},
{Name: "SYS_mutate2"},
@@ -1034,4 +1039,4 @@ var consts_64 = []ConstValue{
{Name: "SYS_unsupported"},
}
-const revision_64 = "74c87d08a1f72c38c85e889813b60823a1e5755c"
+const revision_64 = "8c0a50a6c63e5bd297e9f6421864685e1fd7dc96"
diff --git a/sys/test/test.txt b/sys/test/test.txt
index a087dd47f..51be5d49b 100644
--- a/sys/test/test.txt
+++ b/sys/test/test.txt
@@ -736,6 +736,10 @@ mutate8(a0 proc[100, 4, opt])
open_flags = 0xabababababababab, 0xcdcdcdcdcdcdcdcd
+# Minimization tests.
+
+minimize$0(a0 proc[10, 2], a1 proc[10, 2, opt])
+
# Serialization tests.
serialize0(a ptr[in, serialize0_struct])
diff --git a/sys/test/test_64.const b/sys/test/test_64.const
index 97e3a80b8..f5ed8a6a6 100644
--- a/sys/test/test_64.const
+++ b/sys/test/test_64.const
@@ -8,6 +8,7 @@ SYS_mutate5 = 0
SYS_mutate6 = 0
SYS_mutate7 = 0
SYS_mutate8 = 0
+SYS_minimize = 0
SYS_serialize0 = 0
SYS_serialize1 = 0
SYS_test = 0