aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-12-15 15:17:13 +0100
committerDmitry Vyukov <dvyukov@google.com>2018-12-15 15:17:13 +0100
commitdef91db3fe955168c82038ac2ee39783e81a2af0 (patch)
treeb6cbf100001e7b9fe34a8e2eb4ab00438f3e0154 /sys
parent7a944a0a666587f229291814b30644cc0859674c (diff)
prog, pkg/csource: more readable serialization for strings
Always serialize strings in readable format (non-hex). Serialize binary data in readable format in more cases. Fixes #792
Diffstat (limited to 'sys')
-rw-r--r--sys/test/exec.txt5
-rw-r--r--sys/test/gen/32_fork_shmem.go9
-rw-r--r--sys/test/gen/32_shmem.go9
-rw-r--r--sys/test/gen/64.go15
-rw-r--r--sys/test/gen/64_fork.go9
-rw-r--r--sys/test/test.txt5
-rw-r--r--sys/test/test/strings3
7 files changed, 42 insertions, 13 deletions
diff --git a/sys/test/exec.txt b/sys/test/exec.txt
index 83da4708d..80180ca14 100644
--- a/sys/test/exec.txt
+++ b/sys/test/exec.txt
@@ -3,7 +3,7 @@
syz_mmap(addr vma, len len[addr])
syz_errno(v int32)
-syz_compare(want ptr[in, string], want_len len[want], got ptr[in, compare_data], got_len len[got])
+syz_compare(want ptr[in, string], want_len bytesize[want], got ptr[in, compare_data], got_len bytesize[got])
compare_data [
align0 align0
@@ -11,6 +11,9 @@ compare_data [
bf1 syz_bf_struct1
bf2 syz_bf_struct2
bf3 syz_bf_struct3
+ str string
+ blob array[int8]
+ arr16be array[int16be]
] [varlen]
align0 {
diff --git a/sys/test/gen/32_fork_shmem.go b/sys/test/gen/32_fork_shmem.go
index dfcc705dc..c05ba8b3d 100644
--- a/sys/test/gen/32_fork_shmem.go
+++ b/sys/test/gen/32_fork_shmem.go
@@ -29,6 +29,9 @@ var structDescs_32_fork_shmem = []*KeyedStruct{
&StructType{Key: StructKey{Name: "syz_bf_struct1"}, FldName: "bf1"},
&StructType{Key: StructKey{Name: "syz_bf_struct2"}, FldName: "bf2"},
&StructType{Key: StructKey{Name: "syz_bf_struct3"}, FldName: "bf3"},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "string", FldName: "str", IsVarlen: true}, Kind: 2},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "blob", IsVarlen: true}},
+ &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "arr16be", IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16be", TypeSize: 2}, ArgFormat: 1}}},
}}},
{Key: StructKey{Name: "syz_bf_struct0"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_bf_struct0", TypeSize: 32}, Fields: []Type{
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "syz_bf_flags", FldName: "f0", TypeSize: 2}, BitfieldLen: 10}, Vals: []uint64{0, 1, 2}, BitMask: true},
@@ -72,9 +75,9 @@ var structDescs_32_fork_shmem = []*KeyedStruct{
var syscalls_32_fork_shmem = []*Syscall{
{Name: "syz_compare", CallName: "syz_compare", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "want", TypeSize: 4}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", IsVarlen: true}, Kind: 2}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "want_len", TypeSize: 4}}, Buf: "want"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "want_len", TypeSize: 4}}, BitSize: 8, Buf: "want"},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "got", TypeSize: 4}, Type: &UnionType{Key: StructKey{Name: "compare_data"}}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "got_len", TypeSize: 4}}, Buf: "got"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "got_len", TypeSize: 4}}, BitSize: 8, Buf: "got"},
}},
{Name: "syz_errno", CallName: "syz_errno", Args: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "v", TypeSize: 4}}},
@@ -95,4 +98,4 @@ var consts_32_fork_shmem = []ConstValue{
{Name: "ONLY_32BITS_CONST", Value: 1},
}
-const revision_32_fork_shmem = "f0257b726ddd3b09086a9525a4aae0e0d8cfa6af"
+const revision_32_fork_shmem = "1cb234b0ee2b1630b831f86086747c3e008060c2"
diff --git a/sys/test/gen/32_shmem.go b/sys/test/gen/32_shmem.go
index ba9b6f103..8ccf8a0fc 100644
--- a/sys/test/gen/32_shmem.go
+++ b/sys/test/gen/32_shmem.go
@@ -29,6 +29,9 @@ var structDescs_32_shmem = []*KeyedStruct{
&StructType{Key: StructKey{Name: "syz_bf_struct1"}, FldName: "bf1"},
&StructType{Key: StructKey{Name: "syz_bf_struct2"}, FldName: "bf2"},
&StructType{Key: StructKey{Name: "syz_bf_struct3"}, FldName: "bf3"},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "string", FldName: "str", IsVarlen: true}, Kind: 2},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "blob", IsVarlen: true}},
+ &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "arr16be", IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16be", TypeSize: 2}, ArgFormat: 1}}},
}}},
{Key: StructKey{Name: "syz_bf_struct0"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_bf_struct0", TypeSize: 32}, Fields: []Type{
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "syz_bf_flags", FldName: "f0", TypeSize: 2}, BitfieldLen: 10}, Vals: []uint64{0, 1, 2}, BitMask: true},
@@ -72,9 +75,9 @@ var structDescs_32_shmem = []*KeyedStruct{
var syscalls_32_shmem = []*Syscall{
{Name: "syz_compare", CallName: "syz_compare", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "want", TypeSize: 4}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", IsVarlen: true}, Kind: 2}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "want_len", TypeSize: 4}}, Buf: "want"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "want_len", TypeSize: 4}}, BitSize: 8, Buf: "want"},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "got", TypeSize: 4}, Type: &UnionType{Key: StructKey{Name: "compare_data"}}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "got_len", TypeSize: 4}}, Buf: "got"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "got_len", TypeSize: 4}}, BitSize: 8, Buf: "got"},
}},
{Name: "syz_errno", CallName: "syz_errno", Args: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "v", TypeSize: 4}}},
@@ -95,4 +98,4 @@ var consts_32_shmem = []ConstValue{
{Name: "ONLY_32BITS_CONST", Value: 1},
}
-const revision_32_shmem = "136d60e9280b55ca8a1f24fed877e2f0ae72e348"
+const revision_32_shmem = "8da90b7592aadc1f08e0ae1cb56ecb1ce2d0ad38"
diff --git a/sys/test/gen/64.go b/sys/test/gen/64.go
index d3c24241d..0c7f78426 100644
--- a/sys/test/gen/64.go
+++ b/sys/test/gen/64.go
@@ -76,6 +76,9 @@ var structDescs_64 = []*KeyedStruct{
&StructType{Key: StructKey{Name: "syz_bf_struct1"}, FldName: "bf1"},
&StructType{Key: StructKey{Name: "syz_bf_struct2"}, FldName: "bf2"},
&StructType{Key: StructKey{Name: "syz_bf_struct3"}, FldName: "bf3"},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "string", FldName: "str", IsVarlen: true}, Kind: 2},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "blob", IsVarlen: true}},
+ &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "arr16be", IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16be", TypeSize: 2}, ArgFormat: 1}}},
}}},
{Key: StructKey{Name: "excessive_fields"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "excessive_fields", TypeSize: 1}, Fields: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "f1", TypeSize: 1}}},
@@ -617,9 +620,9 @@ var syscalls_64 = []*Syscall{
}},
{Name: "syz_compare", CallName: "syz_compare", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "want", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", IsVarlen: true}, Kind: 2}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "want_len", TypeSize: 8}}, Buf: "want"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "want_len", TypeSize: 8}}, BitSize: 8, Buf: "want"},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "got", TypeSize: 8}, Type: &UnionType{Key: StructKey{Name: "compare_data"}}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "got_len", TypeSize: 8}}, Buf: "got"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "got_len", TypeSize: 8}}, BitSize: 8, Buf: "got"},
}},
{Name: "syz_errno", CallName: "syz_errno", Args: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "v", TypeSize: 4}}},
@@ -677,6 +680,9 @@ var syscalls_64 = []*Syscall{
{Name: "test$bf1", CallName: "test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_bf_struct1"}}},
}},
+ {Name: "test$blob0", CallName: "test", Args: []Type{
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "array", IsVarlen: true}}},
+ }},
{Name: "test$csum_encode", CallName: "test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_csum_encode"}}},
}},
@@ -865,6 +871,9 @@ var syscalls_64 = []*Syscall{
&ResourceType{TypeCommon: TypeCommon{TypeName: "syz_res", FldName: "a0", TypeSize: 4}},
}},
{Name: "test$res2", CallName: "test", Ret: &ResourceType{TypeCommon: TypeCommon{TypeName: "fd", FldName: "ret", TypeSize: 4, ArgDir: 1}}},
+ {Name: "test$str0", CallName: "test", Args: []Type{
+ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", IsVarlen: true}, Kind: 2}},
+ }},
{Name: "test$struct", CallName: "test", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_struct0"}}},
}},
@@ -940,4 +949,4 @@ var consts_64 = []ConstValue{
{Name: "SYS_unsupported"},
}
-const revision_64 = "ece48c7de48771745acdea340f4c52c47e058e65"
+const revision_64 = "d81730cda36dc2946536413b33737c5635fabb71"
diff --git a/sys/test/gen/64_fork.go b/sys/test/gen/64_fork.go
index 9e93e56c8..4d53ca53e 100644
--- a/sys/test/gen/64_fork.go
+++ b/sys/test/gen/64_fork.go
@@ -29,6 +29,9 @@ var structDescs_64_fork = []*KeyedStruct{
&StructType{Key: StructKey{Name: "syz_bf_struct1"}, FldName: "bf1"},
&StructType{Key: StructKey{Name: "syz_bf_struct2"}, FldName: "bf2"},
&StructType{Key: StructKey{Name: "syz_bf_struct3"}, FldName: "bf3"},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "string", FldName: "str", IsVarlen: true}, Kind: 2},
+ &BufferType{TypeCommon: TypeCommon{TypeName: "array", FldName: "blob", IsVarlen: true}},
+ &ArrayType{TypeCommon: TypeCommon{TypeName: "array", FldName: "arr16be", IsVarlen: true}, Type: &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int16be", TypeSize: 2}, ArgFormat: 1}}},
}}},
{Key: StructKey{Name: "syz_bf_struct0"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "syz_bf_struct0", TypeSize: 32}, Fields: []Type{
&FlagsType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "syz_bf_flags", FldName: "f0", TypeSize: 2}, BitfieldLen: 10}, Vals: []uint64{0, 1, 2}, BitMask: true},
@@ -72,9 +75,9 @@ var structDescs_64_fork = []*KeyedStruct{
var syscalls_64_fork = []*Syscall{
{Name: "syz_compare", CallName: "syz_compare", Args: []Type{
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "want", TypeSize: 8}, Type: &BufferType{TypeCommon: TypeCommon{TypeName: "string", IsVarlen: true}, Kind: 2}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "want_len", TypeSize: 8}}, Buf: "want"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "want_len", TypeSize: 8}}, BitSize: 8, Buf: "want"},
&PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "got", TypeSize: 8}, Type: &UnionType{Key: StructKey{Name: "compare_data"}}},
- &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "got_len", TypeSize: 8}}, Buf: "got"},
+ &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "bytesize", FldName: "got_len", TypeSize: 8}}, BitSize: 8, Buf: "got"},
}},
{Name: "syz_errno", CallName: "syz_errno", Args: []Type{
&IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "v", TypeSize: 4}}},
@@ -94,4 +97,4 @@ var consts_64_fork = []ConstValue{
{Name: "IPPROTO_UDP", Value: 17},
}
-const revision_64_fork = "0c64cdd471dfa62b3e34ed221afe8472c9125d38"
+const revision_64_fork = "8c3363b9502e6df103438d98f573e2ef70ab34f2"
diff --git a/sys/test/test.txt b/sys/test/test.txt
index 214c42c6c..1d49dffa8 100644
--- a/sys/test/test.txt
+++ b/sys/test/test.txt
@@ -11,6 +11,11 @@ test()
test$int(a0 intptr, a1 int8, a2 int16, a3 int32, a4 int64)
+# String types.
+
+test$str0(a ptr[in, string])
+test$blob0(a ptr[in, array[int8]])
+
# Opt arguments
test$opt0(a0 intptr[opt])
diff --git a/sys/test/test/strings b/sys/test/test/strings
new file mode 100644
index 000000000..5b665ba5a
--- /dev/null
+++ b/sys/test/test/strings
@@ -0,0 +1,3 @@
+syz_compare(&AUTO="303100090a0d7022273a", 0xa, &AUTO=@str='01\x00\t\n\rp\"\':', AUTO)
+syz_compare(&AUTO="303100090a0d7022273a01", 0xb, &AUTO=@blob='01\x00\t\n\rp\"\':\x01', AUTO)
+syz_compare(&AUTO="303100090a0d7022273a0102", 0xc, &AUTO=@arr16be=[0x3031, 0x0009, 0x0a0d, 0x7022, 0x273a, 0x0102], AUTO)