• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2017 syzkaller project authors. All rights reserved.
2# Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
3
4# Recursive resources.
5
6resource r0[r0]			### recursive resource r0->r0
7resource r1[r2]			### recursive resource r1->r2->r1
8resource r2[r1]			### recursive resource r2->r1->r2
9resource r3[int32]		### unused resource r3
10
11foo$0(a0 ptr[out, r0], a1 ptr[out, r1], a2 ptr[out, r2])
12
13# Recursive structs/unions.
14
15sr1 {
16	f1	sr1		### recursive declaration: sr1.f1 -> sr1 (mark some pointers as opt)
17}
18
19sr2 {
20	f1	sr3
21	f2	sr4
22}
23
24sr3 {
25	f1	ptr[in, sr3]	### recursive declaration: sr3.f1 -> sr3 (mark some pointers as opt)
26}
27
28sr4 {
29	f1	ptr[in, sr3]
30	f2	array[ptr[in, sr5], 4]	### recursive declaration: sr4.f2 -> sr5.f2 -> sr6.f1 -> sr4 (mark some pointers as opt)
31}
32
33sr5 [
34	f1	int32
35	f2	sr6
36]
37
38sr6 {
39	f1	sr4
40}
41
42sr7 {
43	f1	ptr[in, sr7, opt]
44}
45
46type templ_sr[T] {
47	f	T
48}
49
50sr8 {
51	f	templ_sr[sr8]	### recursive declaration: sr8.f -> templ_sr[sr8].f -> sr8 (mark some pointers as opt)
52}
53
54sr9 {
55	f	templ_sr[ptr[in, sr9]]	### recursive declaration: sr9.f -> templ_sr[ptr[in, sr9]].f -> sr9 (mark some pointers as opt)
56}
57
58use_sr {
59	u2	u2
60		u3	u3
61	s3	s3
62	s4	s4
63	s6	s6
64	sr1 sr1
65	sr2	sr2
66	sr5	sr5
67	sr7	sr7
68	sr8 sr8
69	sr9 sr9
70	s400	s400
71	s401	s401
72	u400	u400
73	u401	u401
74	s402	s402
75	s403	s403
76} [packed]
77
78foo$sr0(a ptr[in, use_sr])
79
80# Len target tests.
81
82foo$100(a int32, b len[a])
83foo$101(a len[a])		### len target a refer to itself
84foo$102(a ptr[in, len[a, int8]])	### len target a refer to itself
85foo$103(a int32, b len[c])	### len target c does not exist
86foo$104(a len[parent])		### len target parent does not exist
87foo$105(a ptr[in, int32], b ptr[in, array[len[a, int32]]])
88foo$106(a int32, b ptr[in, csum[a, inet, int32]])
89foo$107(a int32, b ptr[in, csum[c, inet, int32]])	### csum target c does not exist
90
91s1 {
92	f1	len[s2, int32]	### len target s2 does not exist
93}
94
95s2 {
96	f1	s1
97}
98
99s3 {
100	f1	int8
101} [size[0]]			### size attribute has bad value 0, expect [1, 1<<20]
102
103s4 {
104	f1	int8
105} [size[1000000000]]		### size attribute has bad value 1000000000, expect [1, 1<<20]
106
107s6 {
108	f1	int8
109	f2	array[int8]
110} [size[10]]			### varlen struct s6 has size attribute
111
112u1 [
113	f1	ptr[in, array[int8]]
114	f2	len[f1, int32]	### len target f1 does not exist
115]
116
117u2 [
118	f1	int8
119] [size[0]]			### size attribute has bad value 0, expect [1, 1<<20]
120
121u3 [
122	f1	int8
123] [varlen, size[8]]		### varlen union u3 has size attribute
124
125foo$200(a ptr[in, s2])
126foo$201(a ptr[in, s1])
127foo$202(a u1)
128
129# Resource ctor tests.
130
131resource r100[int32]		### resource r100 can't be created (never mentioned as a syscall return value or output argument/field)
132resource r101[int32]
133resource r102[r101]
134resource r103[r102]
135resource r104[int8]
136resource r105[int8]
137resource r106[int8]		### resource r106 can't be created (never mentioned as a syscall return value or output argument/field)
138resource r107[int8]		### resource r107 can't be created (never mentioned as a syscall return value or output argument/field)
139
140foo$300(a r100)
141foo$301(a ptr[out, array[r103]], b ptr[in, s300], c r107) r104
142
143s300 {
144	f1	ptr[inout, s301]
145	f2	r106
146}
147
148s301 {
149	f2	r105
150}
151
152# Varlen field tests.
153
154s400 {
155	f1	int32
156	f2	array[int8]
157}
158
159s401 {
160	f1	array[int8]
161	f2	array[int8]
162} [packed]
163
164s402 {
165	f1	array[int8]	### variable size field f1 in the middle of non-packed struct s402
166	f2	int32
167}
168
169u400 [
170	f1	array[int8]
171	f2	array[int16]
172] [varlen]
173
174u401 [
175	f1	filename	### variable size field f1 in non-varlen union u401
176	f2	text[x86_64]	### variable size field f2 in non-varlen union u401
177	f3	string		### variable size field f3 in non-varlen union u401
178	f4	string["foo", 10]
179	f5	string[sf400]
180	f6	string[sf401]	### variable size field f6 in non-varlen union u401
181	f7	s401		### variable size field f7 in non-varlen union u401
182]
183
184u402 [
185	f1	int32
186	f2	int32
187] [varlen]
188
189s403 {
190	f1	u400		### variable size field f1 in the middle of non-packed struct s403
191	f2	u402		### variable size field f2 in the middle of non-packed struct s403
192	f3	int32
193}
194
195s404 {				### unused struct s404
196	f1	int8
197}
198
199u404 [				### unused union u404
200	f1	int8
201]
202
203sf400 = "foo", "bar", "baz"
204sf401 = "a", "b", "cd"
205sf402 = "a", "b"		### unused string flags sf402
206
207# Const argument checks.
208
209foo$500(a int32[3:2])		### bad int range [3:2]
210foo$501(a ptr[in, int32[3:2]])	### bad int range [3:2]
211foo$502(a ptr[in, string["foo", C1]])	### string value "foo\x00" exceeds buffer length 1
212foo$503(a ptr[in, proc[1000, 1, int8]])	### values starting from 1000 overflow base type
213foo$504(a ptr[in, proc[20, 10, int8]])	### values starting from 20 with step 10 overflow base type for 32 procs
214foo$505(a proc[20, 0])		### proc per-process values must not be 0
215foo$506(a ptr[in, array[int32, 0]])	### arrays of size 0 are not supported
216foo$507(a ptr[in, array[int32, 0:0]])	### arrays of size 0 are not supported
217foo$508(a ptr[in, string["foo", 3]])	### string value "foo\x00" exceeds buffer length 3
218foo$509(a int8['b':'a'])		### bad int range [98:97]
219foo$510(a type500)
220foo$511(a int32[-10:-20])		### bad int range [18446744073709551606:18446744073709551596]
221foo$512(a ptr[in, array[int8, -2:-1]])	### bad size range [18446744073709551614:18446744073709551615]
222foo$513(a ptr[in, array[int8, -2:2]])	### bad size range [18446744073709551614:2]
223foo$514(a vma[-2:2])			### bad size range [18446744073709551614:2]
224foo$515(a ptr[in, proc[1, -10, int64]])	### values starting from 1 with step 18446744073709551606 overflow base type for 32 procs
225
226type type500 proc[C1, 8, int8]	### values starting from 1 with step 8 overflow base type for 32 procs
227type type501 int8		### unused type type501
228type type502[C] const[C, int8]	### unused type type502
229