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