aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-12-21 14:51:54 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-12-21 14:53:37 +0100
commitbfdfc2603c187447d32ecbc8b5a378df53af5734 (patch)
treecff7440626d57bf7453634c4de4f8e89fc8fc4a6
parentbc5869180f69e2ad6c6b823e129e08a8e523d800 (diff)
prog: don't fail decoding on non-default out args
We get them in cross-compilation test where an out const arg has different values in different archs. No reason to fail deserialization in that case, replace with default arg instead.
-rw-r--r--executor/defs.h2
-rw-r--r--executor/syscalls.h1
-rw-r--r--prog/encoding.go9
-rw-r--r--prog/encoding_test.go5
-rw-r--r--sys/test/gen/64.go5
-rw-r--r--sys/test/test.txt1
6 files changed, 20 insertions, 3 deletions
diff --git a/executor/defs.h b/executor/defs.h
index 9a8d21cae..a8efd5248 100644
--- a/executor/defs.h
+++ b/executor/defs.h
@@ -185,7 +185,7 @@
#if GOARCH_64
#define GOARCH "64"
-#define SYZ_REVISION "854312b077f42679e628a51764359033f376a9d4"
+#define SYZ_REVISION "fd5870a81478a9208df976f4d8066bbdfa12f8e5"
#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 3cb15892a..29ca28644 100644
--- a/executor/syscalls.h
+++ b/executor/syscalls.h
@@ -20713,6 +20713,7 @@ const call_t syscalls[] = {
{"test$opt1", 0},
{"test$opt2", 0},
{"test$opt3", 0},
+ {"test$out_const", 0},
{"test$recur0", 0},
{"test$recur1", 0},
{"test$recur2", 0},
diff --git a/prog/encoding.go b/prog/encoding.go
index 1da491186..e4f762756 100644
--- a/prog/encoding.go
+++ b/prog/encoding.go
@@ -382,7 +382,14 @@ func (p *parser) parseArgInt(typ Type) (Arg, error) {
return nil, fmt.Errorf("wrong arg value '%v': %v", val, err)
}
switch typ.(type) {
- case *ConstType, *IntType, *FlagsType, *ProcType, *LenType, *CsumType:
+ case *ConstType, *IntType, *FlagsType, *ProcType, *CsumType:
+ arg := Arg(MakeConstArg(typ, v))
+ if typ.Dir() == DirOut && !typ.isDefaultArg(arg) {
+ p.strictFailf("out arg %v has non-default value: %v", typ, v)
+ arg = typ.DefaultArg()
+ }
+ return arg, nil
+ case *LenType:
return MakeConstArg(typ, v), nil
case *ResourceType:
return MakeResultArg(typ, nil, v), nil
diff --git a/prog/encoding_test.go b/prog/encoding_test.go
index f828123db..ba7fe3329 100644
--- a/prog/encoding_test.go
+++ b/prog/encoding_test.go
@@ -267,6 +267,11 @@ func TestDeserialize(t *testing.T) {
input: `test$blob0(&AUTO="3031000a0d7022273a01")`,
output: `test$blob0(&(0x7f0000000040)="3031000a0d7022273a01")`,
},
+ {
+ input: `test$out_const(&(0x7f0000000000)=0x2)`,
+ output: `test$out_const(&(0x7f0000000000))`,
+ strictErr: regexp.MustCompile(`out arg const\[1, const\] has non-default value: 2`),
+ },
}
buf := make([]byte, ExecBufferSize)
for _, test := range tests {
diff --git a/sys/test/gen/64.go b/sys/test/gen/64.go
index a9bbd5b51..ce4ca5a73 100644
--- a/sys/test/gen/64.go
+++ b/sys/test/gen/64.go
@@ -1233,6 +1233,9 @@ var syscalls_64 = []*Syscall{
{Name: "test$opt3", CallName: "test", MissingArgs: 5, Args: []Type{
&ProcType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "proc", FldName: "a0", TypeSize: 8, IsOptional: true}}, ValuesStart: 100, ValuesPerProc: 4},
}},
+ {Name: "test$out_const", CallName: "test", MissingArgs: 5, Args: []Type{
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a1", TypeSize: 8}, Type: &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", TypeSize: 4, ArgDir: 1}}, Val: 1}},
+ }},
{Name: "test$recur0", CallName: "test", MissingArgs: 5, Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_recur_0", Dir: 2}}},
}},
@@ -1337,4 +1340,4 @@ var consts_64 = []ConstValue{
{Name: "SYS_unsupported"},
}
-const revision_64 = "854312b077f42679e628a51764359033f376a9d4"
+const revision_64 = "fd5870a81478a9208df976f4d8066bbdfa12f8e5"
diff --git a/sys/test/test.txt b/sys/test/test.txt
index e071ad305..bcbc3462f 100644
--- a/sys/test/test.txt
+++ b/sys/test/test.txt
@@ -541,6 +541,7 @@ test$excessive_args1()
test$excessive_args2(a1 int8)
test$excessive_fields1(a1 ptr[in, excessive_fields])
test$type_confusion1(a1 ptr[in, type_confusion])
+test$out_const(a1 ptr[out, const[1, int32]])
# Bitfields