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).
This commit is contained in:
Dmitry Vyukov 2019-07-26 10:29:11 +02:00
parent 091bb0070f
commit cf49ed5769
7 changed files with 29 additions and 2 deletions

View File

@ -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

View File

@ -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},

View File

@ -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)
}

View File

@ -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 {

View File

@ -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"

View File

@ -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])

View File

@ -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