github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/compiler/testdata/errors2.txt (about) 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 # Errors that happen during checking phase. 5 6 # Recursive resources. 7 8 resource r0[r0] ### recursive resource r0->r0 9 resource r1[r2] ### recursive resource r1->r2->r1 10 resource r2[r1] ### recursive resource r2->r1->r2 11 resource r3[int32] ### unused resource r3 12 13 foo$0(a0 ptr[out, r0], a1 ptr[out, r1], a2 ptr[out, r2]) 14 foo$1(a0 r0, a1 r1, a2 r2) 15 16 # Recursive structs/unions. 17 18 sr1 { 19 f1 sr1 ### recursive declaration: sr1.f1 -> sr1 (mark some pointers as opt) 20 } 21 22 sr2 { 23 f1 sr3 24 f2 sr4 25 } 26 27 sr3 { 28 f1 ptr[in, sr3] ### recursive declaration: sr3.f1 -> sr3 (mark some pointers as opt) 29 } 30 31 sr4 { 32 f1 ptr[in, sr3] 33 f2 array[ptr[in, sr5], 4] ### recursive declaration: sr4.f2 -> sr5.f2 -> sr6.f1 -> sr4 (mark some pointers as opt) 34 } 35 36 sr5 [ 37 f1 int32 38 f2 sr6 39 ] 40 41 sr6 { 42 f1 sr4 43 } 44 45 sr7 { 46 f1 ptr[in, sr7, opt] 47 } 48 49 type templ_sr[T] { 50 f T 51 } 52 53 sr8 { 54 f templ_sr[sr8] ### recursive declaration: sr8.f -> templ_sr[sr8].f -> sr8 (mark some pointers as opt) 55 } 56 57 sr9 { 58 f templ_sr[ptr[in, sr9]] ### recursive declaration: sr9.f -> templ_sr[ptr[in, sr9]].f -> sr9 (mark some pointers as opt) 59 } 60 61 use_sr { 62 u2 u2 63 u3 u3 64 s3 s3 65 s4 s4 66 s6 s6 67 s8 s8 68 sr1 sr1 69 sr2 sr2 70 sr5 sr5 71 sr7 sr7 72 sr8 sr8 73 sr9 sr9 74 s400 s400 75 s401 s401 76 u400 u400 77 u401 u401 78 s402 s402 79 s403 s403 80 } [packed] 81 82 foo$sr0(a ptr[in, use_sr]) 83 84 # Len target tests. 85 86 foo$100(a int32, b len[a]) 87 foo$101(a len[a]) ### len target a refers to itself 88 foo$102(a ptr[in, len[a, int8]]) ### len target a refers to itself 89 foo$103(a int32, b len[c]) ### len target c does not exist in <foo$103> 90 foo$104(a len[parent]) ### parent reached the call (foo$104) 91 foo$105(a ptr[in, int32], b ptr[in, array[len[a, int32]]]) 92 foo$106(a int32, b ptr[in, csum[a, inet, int32]]) 93 foo$107(a int32, b ptr[in, csum[c, inet, int32]]) ### csum target c does not exist in <foo$107> 94 95 s1 { 96 f1 len[s2, int32] ### len target s2 does not exist in s1 97 } 98 99 s2 { 100 f1 s1 101 } 102 103 s3 { 104 f1 int8 105 } [size[0]] ### size attribute has bad value 0, expect [1, 1<<20] 106 107 s4 { 108 f1 int8 109 } [size[1000000000]] ### size attribute has bad value 1000000000, expect [1, 1<<20] 110 111 s6 { 112 f1 int8 113 f2 array[int8] 114 } [size[10]] ### varlen struct s6 has size attribute 115 116 s7 { 117 f1 int32 118 f2 u0 119 } 120 121 s8 { 122 f1 int8 123 } [align[7]] ### bad struct s8 alignment 7 (must be a sane power of 2) 124 125 u0 [ 126 f len[f1, int32] ### len target f1 does not exist in u0 127 ] 128 129 u1 [ 130 f1 ptr[in, array[int8]] 131 f2 len[f1, int32] ### len target f1 does not exist in u1 132 ] 133 134 u2 [ 135 f1 int8 136 ] [size[0]] ### size attribute has bad value 0, expect [1, 1<<20] 137 138 u3 [ 139 f1 int8 140 ] [varlen, size[8]] ### varlen union u3 has size attribute 141 142 foo$200(a ptr[in, s2]) 143 foo$201(a ptr[in, s1]) 144 foo$202(a ptr[in, s7]) 145 foo$203(a u1) 146 147 foo$204(a ptr[in, slen1], b ptr[in, no_slen22]) 148 149 slen1 { 150 f0 len[parent, int32] 151 f1 len[parent:f0, int32] 152 f2 len[slen21:a, int32] ### len target a does not exist in slen2 153 f3 len[f0:parent, int32] ### parent may only stay at the beginning (max 2 times) 154 f4 len[slen2:f, int32] ### len path slen2 does not refer to a struct 155 f5 len[slen22:f, int32] ### len path slen22 does not refer to a struct 156 f6 len[syscall, int32] ### no argument name after syscall reference 157 f7 len[syscall:c, int32] ### len target c does not exist in <foo$204> 158 f8 offsetof[parent, int32] ### offsetof must refer to fields 159 f9 offsetof[slen1, int32] ### offsetof must refer to fields 160 f10 len[f0:syscall:b, int32] ### syscall can't be in the middle of path expressions 161 f11 len[slen3:a, int32] ### len path slen3 does not refer to a struct 162 slen2 ptr[in, array[slen2]] 163 slen21 slen2 164 slen3 slen3 165 slen22 array[slen2] 166 } 167 168 slen2 { 169 f int32 170 f1 slen3 171 f2 len[parent:parent:slen22, int32] ### len target slen22 does not exist in no_slen22 172 } 173 174 slen3 [ 175 a int32 176 b int32 177 c len[parent:parent:parent:x, int32] ### parent may only stay at the beginning (max 2 times) 178 d len[parent:a, int32] ### len target a does not exist in slen3 179 ] 180 181 no_slen22 { 182 # This one violates the parent:parent:slen22 chain. 183 f slen2 184 } 185 186 187 # Resource ctor tests. 188 189 resource r100[int32] ### resource r100 can't be created (never mentioned as a syscall return value or output argument/field) 190 resource r101[int32] 191 resource r102[r101] 192 resource r103[r102] 193 resource r104[int8] 194 resource r105[int8] 195 resource r106[int8] ### resource r106 can't be created (never mentioned as a syscall return value or output argument/field) 196 resource r107[int8] ### resource r107 can't be created (never mentioned as a syscall return value or output argument/field) 197 resource r108[int8] ### resource r108 can't be created (never mentioned as a syscall return value or output argument/field) 198 resource r109[int8] ### resource r109 can't be created (never mentioned as a syscall return value or output argument/field) 199 resource r110[int8] 200 resource r111[int8] 201 resource r112[int8] ### resource r112 can't be created (never mentioned as a syscall return value or output argument/field) 202 resource r113[int8] 203 resource r114[int8] 204 resource r115[int8] ### resource r115 can't be created (never mentioned as a syscall return value or output argument/field) 205 resource r116[int8] ### resource r116 is never used as an input (such resources are not useful) 206 resource r117[int8] ### resource r117 is never used as an input (such resources are not useful) 207 resource r118[int8] ### resource r118 is never used as an input (such resources are not useful) 208 resource r119[int8] ### resource r119 is never used as an input (such resources are not useful) 209 resource r120[int8] ### resource r120 can't be created (never mentioned as a syscall return value or output argument/field) 210 resource r121[int8] ### resource r121 can't be created (never mentioned as a syscall return value or output argument/field) 211 212 foo$300(a0 r100, a1 r101, a2 r102, a3 r103, a4 r104, a5 r105, a6 r106, a7 r107, a8 r108) 213 foo$301(a0 r109, a1 r110, a2 r111, a3 r112, a4 r113, a5 r114, a6 r115, a7 r120) 214 foo$302(a ptr[out, array[r103]], b ptr[in, s300], c r107) r104 215 foo$303(a ptr[in, s302], b ptr[in, s303], c ptr[in, s304], d ptr[out, s305], e ptr[inout, s306], f ptr[inout, s307], g ptr[in, s308], h ptr[out, s310]) 216 foo$304(a ptr[out, r117], b ptr[in, s312], c ptr[in, s313]) r116 217 foo$305(a0 r121) 218 foo$306(a0 ptr[out, u315]) 219 220 s300 { 221 f1 ptr[inout, s301] 222 f2 r106 223 } 224 225 s301 { 226 f2 r105 227 } 228 229 s302 { 230 f1 r108 231 } 232 233 s303 { 234 f1 r109 (in) 235 } 236 237 # ptr to struct is in, field is out (valid, resource can be created) 238 s304 { 239 f1 r110 (out) 240 } 241 242 # ptr to struct is out, field is in (error, resource can't be created) 243 s305 { 244 f1 r111 (in) 245 } 246 247 # ptr to struct is inout, field is inout (valid, resource can be created) 248 s306 { 249 f1 r111 (inout) 250 } 251 252 # ptr to struct is inout, fields are in (error) and out (valid) 253 s307 { 254 f1 r112 (in) 255 f2 r113 (out) 256 } 257 258 # recurse the out field inside two levels of in ptrs (valid, resource can be created) 259 s308 { 260 f1 ptr[in, s309] 261 } 262 263 s309 { 264 f1 ptr[out, r114] 265 } 266 267 # recurse the in field inside two levels of out ptrs (error, resource can't be created) 268 s310 { 269 f1 ptr[out, s311] 270 } 271 272 s311 { 273 f1 ptr[in, r115] 274 } 275 276 # ptr to struct is in, field is out (error, never used as an input) 277 s312 { 278 f1 r118 (out) 279 } 280 281 # recurse the out field inside two levels of in ptrs (error, never used as an input) 282 s313 { 283 f1 ptr[in, s314] 284 } 285 286 s314 { 287 f1 r119 (out) 288 } 289 290 u315 [ 291 f1 r121 292 f2 int32 293 ] 294 295 # TODO: Two instances of the same resource might exist in the same structure as 296 # both in and out. How common is this and how to handle this? 297 298 # Varlen field tests. 299 300 s400 { 301 f1 int32 302 f2 array[int8] 303 } 304 305 s401 { 306 f1 array[int8] 307 f2 array[int8] 308 } [packed] 309 310 s402 { 311 f1 array[int8] ### variable size field f1 in the middle of non-packed struct s402 312 f2 int32 313 } 314 315 u400 [ 316 f1 array[int8] 317 f2 array[int16] 318 ] [varlen] 319 320 u401 [ 321 f1 filename ### variable size field f1 in non-varlen union u401 322 f2 text[x86_64] ### variable size field f2 in non-varlen union u401 323 f3 string ### variable size field f3 in non-varlen union u401 324 f4 string["foo", 10] 325 f5 string[sf400] 326 f6 string[sf401] ### variable size field f6 in non-varlen union u401 327 f7 s401 ### variable size field f7 in non-varlen union u401 328 ] 329 330 u402 [ 331 f1 int32 332 f2 int32 333 ] [varlen] 334 335 s403 { 336 f1 u400 ### variable size field f1 in the middle of non-packed struct s403 337 f2 u402 ### variable size field f2 in the middle of non-packed struct s403 338 f3 int32 339 } 340 341 s404 { ### unused struct s404 342 f1 int8 343 } 344 345 u404 [ ### unused union u404 346 f1 int8 347 ] 348 349 sf400 = "foo", "bar", "baz" 350 sf401 = "a", "b", "cd" 351 sf402 = "a", "b" ### unused string flags sf402 352 353 # Const argument checks. 354 355 foo$500(a int32[3:2]) ### bad int range [3:2] 356 foo$501(a ptr[in, int32[3:2]]) ### bad int range [3:2] 357 foo$502(a ptr[in, string["foo", C1]]) ### string value "foo\x00" exceeds buffer length 1 358 foo$503(a ptr[in, proc[1000, 1, int8]]) ### values starting from 1000 overflow base type 359 foo$504(a ptr[in, proc[20, 10, int8]]) ### values starting from 20 with step 10 overflow base type for 32 procs 360 foo$505(a proc[20, 0]) ### proc per-process values must not be 0 361 foo$506(a ptr[in, array[int32, 0]]) ### arrays of size 0 are not supported 362 foo$507(a ptr[in, array[int32, 0:0]]) ### arrays of size 0 are not supported 363 foo$508(a ptr[in, string["foo", 3]]) ### string value "foo\x00" exceeds buffer length 3 364 foo$509(a int8['b':'a']) ### bad int range [98:97] 365 foo$510(a type500) 366 foo$511(a int32[-10:-20]) ### bad int range [18446744073709551606:18446744073709551596] 367 foo$512(a ptr[in, array[int8, -2:-1]]) ### bad size range [18446744073709551614:18446744073709551615] 368 foo$513(a ptr[in, array[int8, -2:2]]) ### bad size range [18446744073709551614:2] 369 foo$514(a vma[-2:2]) ### bad size range [18446744073709551614:2] 370 foo$515(a ptr[in, proc[1, -10, int64]]) ### values starting from 1 with step 18446744073709551606 overflow base type for 32 procs 371 foo$516(a ptr[in, intptr[0:2, 1]]) ### bad int alignment 1 372 foo$517(a intptr[0:0xffffffff, 0]) ### bad int alignment 0 373 foo$518(a int64[1:100, -1]) ### int alignment 18446744073709551615 is too large for range [1:100] 374 foo$519(a int64[0:10, 512]) ### int alignment 512 is too large for range [0:10] 375 foo$520(a int8[0:16, 0xffff]) ### int alignment 65535 is too large for range [0:16] 376 foo$521(a int32[9:10, 8]) ### int alignment 8 is too large for range [9:10] 377 foo$522(a int8[0:-1, 1000]) ### int alignment 1000 is too large for range [0:255] 378 foo$523(a int8[0:256]) ### int range [0:256] is too large for base type of size 8 379 foo$524(a int8[-1000:0]) ### int range [18446744073709550616:0] is too large for base type of size 8 380 foo$525(a int8[-256:256]) ### int range [18446744073709551360:256] is too large for base type of size 8 381 foo$526(a int8[-255:255]) ### int range [18446744073709551361:255] is too large for base type of size 8 382 foo$527(a int16[-40000:40000]) ### int range [18446744073709511616:40000] is too large for base type of size 16 383 foo$528(a ptr[in, s405]) 384 foo$529(a ptr[in, string[`abcdde`, 3]]) ### string value "\xab\xcd\xde\x00" exceeds buffer length 3 385 foo$530(a ptr[in, const[0x1ab, int8]]) ### const val 0x1ab does not fit into 8 bits 386 foo$531(a ptr[in, const[0xffffffffffffffab, int8]]) 387 foo$532(a ptr[in, const[0x7234567812345678, int64]]) 388 foo$533(a ptr[in, const[0x12, int8:4]]) ### const val 0x12 does not fit into 4 bits 389 foo$534(a ptr[in, flags[large_flags, int8]]) ### large_flags U16_MAX=0xffff doesn't fit into 8 bits 390 foo$535(a int64[no]) ### unknown flags no 391 392 large_flags = U8_MAX, U16_MAX 393 394 equal_flags_0 = 0, 0, 0, 0 ### all equal_flags_0 values are equal 0 395 equal_flags_1 = 42, 42, 42, 42 ### all equal_flags_1 values are equal 42 396 non_equal_flags = 0, 0, 0, 1 397 398 equal_flags_call(a flags[equal_flags_0], b flags[equal_flags_1], c flags[non_equal_flags]) 399 400 type type500 proc[C1, 8, int8] ### values starting from 1 with step 8 overflow base type for 32 procs 401 type type501 int8 ### unused type type501 402 type type502[C] const[C, int8] ### unused type type502 403 404 C2 = 0, 1, 2 ### const C2 is already a flag 405 use_flags(a flags[C2]) 406 407 s405 { 408 f1 int16:8[-256:0] ### int range [18446744073709551360:0] is too large for base type of size 8 409 f2 int16:8[0:256] ### int range [0:256] is too large for base type of size 8 410 f3 int64:16[-65541:-10] ### int range [18446744073709486075:18446744073709551606] is too large for base type of size 16 411 f4 int16:8[-255:0] ### int range [18446744073709551361:0] is too large for base type of size 8 412 } 413 414 # Field attributes. 415 416 foo$overlay(a ptr[in, struct$overlay0], b ptr[in, struct$out0]) 417 418 struct$overlay0 { 419 f0 int32 420 f1 const[0, int32] (out_overlay) ### const type must not be used as output 421 f2 ptr[in, int32] ### ptr type must not be used as output 422 f3 proc[0, 1, int32] ### proc type must not be used as output 423 f4 bytesize[f1, int32] ### bytesize type must not be used as output 424 } 425 426 struct$out0 { 427 f0 const[0, int32] (out) ### const type must not be used as output 428 f1 ptr[in, int32] (out) ### ptr type must not be used as output 429 f2 proc[0, 1, int32] (out) ### proc type must not be used as output 430 f3 bytesize[f1, int32] (out) ### bytesize type must not be used as output 431 } 432 433 struct_non_generatable { 434 f0 ptr[in, array[compressed_image]] 435 } 436 437 union_non_minimizable [ 438 f0 struct_non_generatable 439 f2 int32 440 ] 441 442 foo$non_generatable(a compressed_image) (no_minimize) ### call foo$non_generatable refers to type compressed_image and so must be marked no_generate 443 foo$non_minimizable(a compressed_image) (no_generate) ### call foo$non_minimizable refers to type compressed_image and so must be marked no_minimize 444 foo$non_generatable_via_struct(a ptr[in, struct_non_generatable]) (no_minimize) ### call foo$non_generatable_via_struct refers to type compressed_image and so must be marked no_generate 445 foo$non_minimizable_via_union(a ptr[in, union_non_minimizable]) (no_generate) ### call foo$non_minimizable_via_union refers to type compressed_image and so must be marked no_minimize 446 447 resource for_fmt[int32] 448 foo$fmt_copyin(a ptr[in, fmt[dec, for_fmt]]) 449 foo$fmt_copyout(a ptr[out, fmt[dec, for_fmt]]) ### resource for_fmt cannot be created in fmt 450 451 452 define FLAG1 1 453 define FLAG2 2 454 455 some_nested_nested_flags { 456 f4 int32 457 } 458 459 some_nested_flags { 460 f1 int32 461 f2 array[some_nested_nested_flags] 462 f4 for_fmt 463 f5 int32 (if[value[f1] == 0]) 464 f6 some_nested_nested_flags 465 } [packed] 466 467 conditional_fields { 468 f1 int32 469 f2 some_nested_flags (if[value[f1] & FLAG1]) 470 f3 some_nested_flags 471 f4 int32 (if[value[f3:f1] != 0]) 472 f5 int32 (if[value[f3:f2:f4] != 0]) ### value path f2 does not refer to a struct 473 f6 int32 (if[value[f3:f4] != 0]) ### f4 does not refer to an integer or a flag 474 f7 int32 (if[value[f3:some_field] != 0]) ### value target some_field does not exist in some_nested_flags 475 f8 int32 (if[value[f3:f5] != 0]) ### f5 has conditions, so value path cannot reference it 476 f9 int32 (if[value[parent:a] != 0]) ### value target a does not exist in conditional_fields 477 f10 int32 (if[value[f3:f6] != 0]) ### f6 does not refer to an integer or a flag 478 f11 len[f2, int32] ### f2 has conditions, so len path cannot reference it 479 f12 union_cond_fields 480 f13 int32:8 (if[1]) ### bitfields may not have conditions 481 } [packed] 482 483 union_cond_fields [ 484 u1 int32 (if[value[parent:parent:f1] != 0]) 485 u2 int32 (if[value[parent:parent:unknown] != 0]) ### value target unknown does not exist in conditional_fields 486 u3 int64 487 ] 488 489 foo$conditional(a ptr[in, conditional_fields]) 490 491 conditional_non_packed { 492 f0 int64 493 f1 conditional_non_packed_nested ### variable size field f1 in the middle of non-packed struct conditional_non_packed 494 f2 int64 495 } 496 497 conditional_non_packed_nested { 498 f3 int64 (if[value[parent:parent:f0]]) 499 f4 int32 500 } [packed] 501 502 foo$conditional2(a ptr[in, conditional_non_packed]) 503 504 conditional_non_packed2 { 505 f0 int64 506 f1 int8 (if[value[f0] == 0]) ### variable size field f1 in the middle of non-packed struct conditional_non_packed2 507 f2 int64 508 } 509 510 foo$conditional3(a ptr[in, conditional_non_packed2])