| 1 |
class process |
| 2 |
class blk_file |
| 3 |
class chr_file |
| 4 |
class dir |
| 5 |
class fifo_file |
| 6 |
class file |
| 7 |
class lnk_file |
| 8 |
class sock_file |
| 9 |
|
| 10 |
sid kernel |
| 11 |
sid security |
| 12 |
sid unlabeled |
| 13 |
sid file |
| 14 |
sid port |
| 15 |
sid netif |
| 16 |
sid netmsg |
| 17 |
sid node |
| 18 |
sid devnull |
| 19 |
|
| 20 |
class process { dyntransition transition } |
| 21 |
class file { getattr ioctl open read write } |
| 22 |
|
| 23 |
bool boolean1 false; |
| 24 |
bool boolean2 true; |
| 25 |
|
| 26 |
ifdef(`enable_mls',` |
| 27 |
sensitivity s0; |
| 28 |
dominance { s0 } |
| 29 |
category c0; category c1; category c2; category c3; |
| 30 |
category c4; category c5; category c6; category c7; |
| 31 |
category c8; category c9; category c10; category c11; |
| 32 |
category c12; category c13; category c14; category c15; |
| 33 |
category c16; category c17; category c18; category c19; |
| 34 |
category c20; category c21; category c22; category c23; |
| 35 |
|
| 36 |
level s0:c0.c23; |
| 37 |
|
| 38 |
mlsconstrain file { write } ( h1 dom h2 ); |
| 39 |
') |
| 40 |
|
| 41 |
|
| 42 |
######################################## |
| 43 |
# |
| 44 |
# Test start |
| 45 |
# |
| 46 |
######################################## |
| 47 |
|
| 48 |
|
| 49 |
## Test 1 (basic - fail) |
| 50 |
|
| 51 |
type test1_t; |
| 52 |
if boolean1 { |
| 53 |
allow test1_t self : file read; |
| 54 |
} |
| 55 |
neverallow test1_t * : file *; |
| 56 |
|
| 57 |
|
| 58 |
## Test 2 (basic - fail) |
| 59 |
|
| 60 |
attribute test2_a; |
| 61 |
type test2_1_t, test2_a; |
| 62 |
type test2_2_t; |
| 63 |
if !boolean1 { |
| 64 |
allow test2_1_t test2_1_t : file write; |
| 65 |
allow test2_2_t test2_2_t : file write; |
| 66 |
} |
| 67 |
neverallow test2_a * : file *; |
| 68 |
|
| 69 |
|
| 70 |
## Test 3 (xperm - no xperm in one branch - fail) |
| 71 |
|
| 72 |
type test3_t; |
| 73 |
if boolean1 { |
| 74 |
allow test3_t self : file ioctl; |
| 75 |
} else { |
| 76 |
allowxperm test3_t self : file ioctl 0x1; |
| 77 |
} |
| 78 |
neverallowxperm test3_t self : file ioctl 0x4; |
| 79 |
|
| 80 |
|
| 81 |
## Test 4 (xperm - xperm in neither branch - fail) |
| 82 |
|
| 83 |
type test4_t; |
| 84 |
allow test4_t self : file ioctl; |
| 85 |
if boolean1 { |
| 86 |
allow test4_t self : file read; |
| 87 |
} else { |
| 88 |
allow test4_t self : file write; |
| 89 |
} |
| 90 |
neverallowxperm test4_t self : file ioctl 0x4; |
| 91 |
|
| 92 |
|
| 93 |
## Test 5 (xperm - xperm in both branches - no failure) |
| 94 |
|
| 95 |
type test5_t; |
| 96 |
allow test5_t self : file ioctl; |
| 97 |
if boolean1 { |
| 98 |
allowxperm test5_t self : file ioctl 0x1; |
| 99 |
} else { |
| 100 |
allowxperm test5_t self : file ioctl 0x2; |
| 101 |
} |
| 102 |
neverallowxperm test5_t self : file ioctl 0x4; # nofail |
| 103 |
|
| 104 |
|
| 105 |
## Test 6 (xperm - failure in one branch - fail) |
| 106 |
|
| 107 |
type test6_t; |
| 108 |
if boolean1 { |
| 109 |
allow test6_t self : file ioctl; |
| 110 |
allowxperm test6_t self : file ioctl 0x1; |
| 111 |
} else { |
| 112 |
allow test6_t self : file write; |
| 113 |
} |
| 114 |
neverallowxperm test6_t self : file ioctl 0x1; |
| 115 |
|
| 116 |
|
| 117 |
## Test 7 (xperm - failure in both branches - fail) |
| 118 |
|
| 119 |
type test7_t; |
| 120 |
if boolean1 { |
| 121 |
allow test7_t self : file ioctl; |
| 122 |
allowxperm test7_t self : file ioctl 0x1; |
| 123 |
} else { |
| 124 |
allow test7_t self : file ioctl; |
| 125 |
allowxperm test7_t self : file ioctl 0x2; |
| 126 |
} |
| 127 |
neverallowxperm test7_t self : file ioctl { 0x1-0x2 }; |
| 128 |
|
| 129 |
|
| 130 |
## Test 8 (xperm - different xperm in both branches - no failure) |
| 131 |
|
| 132 |
type test8_t; |
| 133 |
allow test8_t self : file ioctl; |
| 134 |
if boolean1 { |
| 135 |
allowxperm test8_t self : file ioctl 0x1; |
| 136 |
} else { |
| 137 |
allowxperm test8_t self : file ioctl 0x2; |
| 138 |
} |
| 139 |
neverallowxperm test8_t self : file ioctl 0x3; # nofail |
| 140 |
|
| 141 |
|
| 142 |
## Test 9 (xperm - rules split into two booleans - no failure) |
| 143 |
|
| 144 |
type test9_t; |
| 145 |
allow test9_t self : file ioctl; |
| 146 |
if boolean1 { |
| 147 |
allowxperm test9_t self : file ioctl 0x1; |
| 148 |
} |
| 149 |
if !boolean2 { |
| 150 |
allowxperm test9_t self : file ioctl 0x1; |
| 151 |
} |
| 152 |
neverallowxperm test9_t self : file ioctl 0x4; |
| 153 |
|
| 154 |
|
| 155 |
## Test 10 (xperm - valid usage in one branch - no failure) |
| 156 |
|
| 157 |
type test10_t; |
| 158 |
if boolean1 { |
| 159 |
allow test10_t self : file ioctl; |
| 160 |
allowxperm test10_t self : file ioctl 0x1; |
| 161 |
} else { |
| 162 |
allow test10_t self : file write; |
| 163 |
} |
| 164 |
neverallowxperm test10_t self : file ioctl 0x2; # nofail |
| 165 |
|
| 166 |
|
| 167 |
## Test 11 (xperm - valid usage in both branches - no failure) |
| 168 |
|
| 169 |
type test11_t; |
| 170 |
if boolean1 { |
| 171 |
allow test11_t self : file ioctl; |
| 172 |
allowxperm test11_t self : file ioctl 0x1; |
| 173 |
} else { |
| 174 |
allow test11_t self : file ioctl; |
| 175 |
allowxperm test11_t self : file ioctl 0x2; |
| 176 |
} |
| 177 |
neverallowxperm test11_t self : file ioctl 0x3; # nofail |
| 178 |
|
| 179 |
|
| 180 |
## Test 12 (xperm - base allow in one branch - fail) |
| 181 |
|
| 182 |
type test12_t; |
| 183 |
if boolean1 { |
| 184 |
allow test12_t self : file ioctl; |
| 185 |
} else { |
| 186 |
allow test12_t self : file write; |
| 187 |
} |
| 188 |
neverallowxperm test12_t self : file ioctl 0x1; |
| 189 |
|
| 190 |
|
| 191 |
## Test 13 (xperm - invalid second branch - fail) |
| 192 |
|
| 193 |
type test13_t; |
| 194 |
allow test13_t self : file ioctl; |
| 195 |
if boolean1 { |
| 196 |
allow test13_t self : file ioctl; |
| 197 |
allowxperm test13_t self : file ioctl 0x1; |
| 198 |
} else { |
| 199 |
allow test13_t self : file write; |
| 200 |
} |
| 201 |
neverallowxperm test13_t self : file ioctl 0x1; |
| 202 |
|
| 203 |
|
| 204 |
## Test 14 (xperm - invalid second branch - fail) |
| 205 |
|
| 206 |
type test14_t; |
| 207 |
allow test14_t self : file ioctl; |
| 208 |
if boolean1 { |
| 209 |
allow test14_t self : file ioctl; |
| 210 |
allowxperm test14_t self : file ioctl 0x1; |
| 211 |
} else { |
| 212 |
allow test14_t self : file write; |
| 213 |
} |
| 214 |
neverallowxperm test14_t self : file ioctl 0x2; |
| 215 |
|
| 216 |
|
| 217 |
## Test 15 (xperm - base uncond in one branch - fail) |
| 218 |
|
| 219 |
type test15_t; |
| 220 |
allow test15_t self : file ioctl; |
| 221 |
allowxperm test15_t self : file ioctl 0x1; |
| 222 |
if boolean1 { |
| 223 |
allow test15_t self : file ioctl; |
| 224 |
} else { |
| 225 |
allow test15_t self : file write; |
| 226 |
} |
| 227 |
neverallowxperm test15_t self : file ioctl 0x2; |
| 228 |
|
| 229 |
|
| 230 |
######################################## |
| 231 |
# |
| 232 |
# Test End |
| 233 |
# |
| 234 |
######################################## |
| 235 |
|
| 236 |
|
| 237 |
type sys_isid; |
| 238 |
role sys_role; |
| 239 |
role sys_role types sys_isid; |
| 240 |
gen_user(sys_user,, sys_role, s0, s0 - s0:c0.c23) |
| 241 |
sid kernel gen_context(sys_user:sys_role:sys_isid, s0) |
| 242 |
sid security gen_context(sys_user:sys_role:sys_isid, s0) |
| 243 |
sid unlabeled gen_context(sys_user:sys_role:sys_isid, s0) |
| 244 |
sid file gen_context(sys_user:sys_role:sys_isid, s0) |
| 245 |
sid port gen_context(sys_user:sys_role:sys_isid, s0) |
| 246 |
sid netif gen_context(sys_user:sys_role:sys_isid, s0) |
| 247 |
sid netmsg gen_context(sys_user:sys_role:sys_isid, s0) |
| 248 |
sid node gen_context(sys_user:sys_role:sys_isid, s0) |
| 249 |
sid devnull gen_context(sys_user:sys_role:sys_isid, s0) |
| 250 |
fs_use_trans devpts gen_context(sys_user:sys_role:sys_isid, s0); |
| 251 |
fs_use_trans devtmpfs gen_context(sys_user:sys_role:sys_isid, s0); |