github.com/google/syzkaller@v0.0.0-20251211124644-a066d2bc4b02/sys/test/expressions.txt (about) 1 # Copyright 2023 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 # Syscalls used for testing conditional expressions. 5 6 define FIELD_FLAG1 2 7 define FIELD_FLAG2 4 8 9 field1 { 10 f1 const[0xffffffff, int32] 11 } 12 13 conditional_struct { 14 mask int32 15 f1 field1 (if[value[mask] & FIELD_FLAG1]) 16 f2 int64 (if[value[mask] & FIELD_FLAG2]) 17 f3 int32 (if[value[mask] == FIELD_FLAG1 || value[mask] == FIELD_FLAG2]) 18 } [packed] 19 20 resource some_res[int32] 21 22 test$conditional_struct(a ptr[in, conditional_struct]) some_res 23 24 # To generate this call, we need to recursively also generate a test$conditional_struct() call. 25 26 needs_some_res { 27 switch int32 28 field some_res (if[value[switch] != 0]) 29 } 30 31 resource some_res_nested[int32] 32 test$conditional_struct_nested(a ptr[in, needs_some_res]) some_res_nested 33 34 # .. and one more level. 35 36 needs_some_res_nested { 37 switch int32 38 field some_res_nested (if[value[switch] != 0]) 39 } 40 41 test$conditional_struct_nested2(a ptr[in, needs_some_res_nested]) 42 43 parent_conditions { 44 mask int32 45 u parent_conditions_nested_union 46 s parent_conditions_nested_struct 47 } [packed] 48 49 parent_conditions_nested_union [ 50 with_flag1 int32 (if[value[parent:parent:mask] & FIELD_FLAG1]) 51 without_flag1 int64 52 ] 53 54 parent_conditions_nested_struct { 55 f0 int64 56 f1 int32 (if[value[parent_conditions:mask] & FIELD_FLAG2]) 57 } 58 59 test$parent_conditions(a ptr[in, parent_conditions]) 60 61 condition_and_align { 62 f0 int8 63 f1 int32 (if[value[f0] == 1]) 64 f2 int8 65 } [packed, align[4]] 66 67 condition_parent_align { 68 f0 int8 69 f1 condition_and_align 70 f2 int8 71 } [packed, align[4]] 72 73 conditional_struct_minimize { 74 havef0 int8 75 f0 int8 (if[value[havef0] == 1]) 76 havef1 int8 77 f1 int8 (if[value[havef1] == 1]) 78 } [packed] 79 80 test$conditional_struct_minimize(a ptr[in, conditional_struct_minimize]) 81 82 conditional_union [ 83 u1 int8 (if[value[conditional_union_parent:f1] == 0]) 84 u2 int8 85 ] 86 87 conditional_union_parent { 88 f1 int8:1 89 f2 conditional_union 90 } 91 92 test$conditional_union(a ptr[in, conditional_union_parent]) 93 94 resource cond_res[int32] 95 96 test$create_cond_resource() cond_res 97 98 conditional_resouce_struct { 99 f0 int8 100 f1 cond_res (if[value[f0] == 1]) 101 } 102 103 test$use_cond_resource(a ptr[in, conditional_resouce_struct])