| 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 |
ifdef(`enable_mls',` |
| 24 |
sensitivity s0; |
| 25 |
dominance { s0 } |
| 26 |
category c0; category c1; category c2; category c3; |
| 27 |
category c4; category c5; category c6; category c7; |
| 28 |
category c8; category c9; category c10; category c11; |
| 29 |
category c12; category c13; category c14; category c15; |
| 30 |
category c16; category c17; category c18; category c19; |
| 31 |
category c20; category c21; category c22; category c23; |
| 32 |
|
| 33 |
level s0:c0.c23; |
| 34 |
|
| 35 |
mlsconstrain file { write } ( h1 dom h2 ); |
| 36 |
') |
| 37 |
|
| 38 |
|
| 39 |
######################################## |
| 40 |
# |
| 41 |
# Test start |
| 42 |
# |
| 43 |
######################################## |
| 44 |
|
| 45 |
|
| 46 |
## Test 1 (basic) |
| 47 |
|
| 48 |
type test1_t; |
| 49 |
allow test1_t test1_t : file { read write }; |
| 50 |
neverallow test1_t test1_t : file read; |
| 51 |
|
| 52 |
|
| 53 |
## Test 2 (wildcard permission) |
| 54 |
|
| 55 |
type test2_t; |
| 56 |
allow test2_t test2_t : file { read write }; |
| 57 |
neverallow test2_t test2_t : file *; |
| 58 |
|
| 59 |
|
| 60 |
## Test 3 (complement permission) |
| 61 |
|
| 62 |
type test3_t; |
| 63 |
allow test3_t test3_t : file { read write }; |
| 64 |
neverallow test3_t test3_t : file ~{ write }; |
| 65 |
|
| 66 |
|
| 67 |
## Test 4 (wildcard source) |
| 68 |
|
| 69 |
type test4_t; |
| 70 |
allow test4_t test4_t : file { read write }; |
| 71 |
neverallow * test4_t : file read; |
| 72 |
|
| 73 |
|
| 74 |
## Test 5 (wildcard target) |
| 75 |
|
| 76 |
type test5_t; |
| 77 |
allow test5_t test5_t : file { read write }; |
| 78 |
neverallow test5_t * : file read; |
| 79 |
|
| 80 |
|
| 81 |
## Test 6 (complement source) |
| 82 |
|
| 83 |
type test6_1_t; |
| 84 |
type test6_2_t; |
| 85 |
allow { test6_1_t test6_2_t } { test6_1_t test6_2_t } : file { read write }; |
| 86 |
neverallow ~{ test6_2_t } test6_1_t : file read; |
| 87 |
|
| 88 |
|
| 89 |
## Test 7 (complement target) |
| 90 |
|
| 91 |
type test7_1_t; |
| 92 |
type test7_2_t; |
| 93 |
allow { test7_1_t test7_2_t } { test7_1_t test7_2_t } : file { read write }; |
| 94 |
neverallow test7_1_t ~{ test7_2_t } : file read; |
| 95 |
|
| 96 |
|
| 97 |
## Test 8 (source attribute) |
| 98 |
|
| 99 |
attribute test8_a; |
| 100 |
type test8_t, test8_a; |
| 101 |
allow test8_a test8_a : file read; |
| 102 |
allow test8_t test8_t : file write; |
| 103 |
neverallow test8_a test8_t : file { read write }; |
| 104 |
|
| 105 |
|
| 106 |
## Test 9 (target attribute) |
| 107 |
|
| 108 |
attribute test9_a; |
| 109 |
type test9_t, test9_a; |
| 110 |
allow test9_a test9_a : file read; |
| 111 |
allow test9_t test9_t : file write; |
| 112 |
neverallow test9_t test9_a : file { read write }; |
| 113 |
|
| 114 |
|
| 115 |
## Test 10 (self) |
| 116 |
|
| 117 |
attribute test10_a; |
| 118 |
type test10_1_t, test10_a; |
| 119 |
type test10_2_t; |
| 120 |
allow { test10_1_t test10_2_t } { test10_1_t test10_2_t } : file read; |
| 121 |
neverallow test10_a self : file *; |
| 122 |
|
| 123 |
|
| 124 |
## Test 11 (wildcard) |
| 125 |
|
| 126 |
type test11_t; |
| 127 |
allow test11_t self : process *; |
| 128 |
neverallow * * : process *; |
| 129 |
|
| 130 |
|
| 131 |
## Test 12 (complement attributes) |
| 132 |
|
| 133 |
attribute test12_1_a; |
| 134 |
attribute test12_2_a; |
| 135 |
attribute test12_3_a; |
| 136 |
type test12_1_t, test12_1_a; |
| 137 |
type test12_2_t, test12_2_a; |
| 138 |
type test12_3_t, test12_3_a; |
| 139 |
allow { test12_1_a test12_2_a test12_3_a } { test12_1_a test12_2_a test12_3_a } : file *; |
| 140 |
neverallow ~{ test12_1_a test12_2_t } ~{ test12_3_a } : file getattr; |
| 141 |
neverallow ~{ test12_1_a } ~{ test12_2_a test12_3_t } : file open; |
| 142 |
|
| 143 |
|
| 144 |
## Test 13 (excludes) |
| 145 |
|
| 146 |
attribute test13_1_a; |
| 147 |
attribute test13_2_a; |
| 148 |
attribute test13_3_a; |
| 149 |
type test13_1_t, test13_1_a; |
| 150 |
type test13_2_t, test13_2_a; |
| 151 |
type test13_3_t, test13_3_a; |
| 152 |
allow { test13_1_a test13_2_a test13_3_a } { test13_1_a test13_2_a test13_3_a } : file { read write }; |
| 153 |
neverallow { test13_1_a test13_2_a test13_3_a -test13_2_a -test13_3_t } { test13_1_a test13_2_a test13_3_a -test13_2_t -test13_3_a } : file read; |
| 154 |
|
| 155 |
|
| 156 |
## Test 14 (misc avrules) |
| 157 |
|
| 158 |
type test14_t; |
| 159 |
auditallow test14_t test14_t : file read; |
| 160 |
dontaudit test14_t test14_t : file write; |
| 161 |
neverallow test14_t test14_t : file { read write }; |
| 162 |
type_transition test14_t test14_t : file test14_t; |
| 163 |
type_transition test14_t test14_t : file test14_t "objname"; |
| 164 |
neverallow test14_t test14_t : file *; # nofail |
| 165 |
|
| 166 |
|
| 167 |
## Test 15 (extended permissions - standard allow) |
| 168 |
|
| 169 |
type test15_t; |
| 170 |
allow test15_t self : file ioctl; |
| 171 |
neverallowxperm test15_t self : file ioctl 0x1111; |
| 172 |
|
| 173 |
|
| 174 |
## Test 16 (extended permissions - allowxperm) |
| 175 |
|
| 176 |
type test16_t; |
| 177 |
allow test16_t self : file ioctl; |
| 178 |
allowxperm test16_t self : file ioctl 0x1111; |
| 179 |
neverallowxperm test16_t self : file ioctl 0x1111; |
| 180 |
|
| 181 |
|
| 182 |
## Test 17 (extended permissions - allowxperm mismatch) |
| 183 |
|
| 184 |
type test17_t; |
| 185 |
allow test17_t self : file ioctl; |
| 186 |
allowxperm test17_t self : file ioctl 0x1111; |
| 187 |
neverallowxperm test17_t self : file ioctl 0x2222; # nofail |
| 188 |
|
| 189 |
|
| 190 |
## Test 18 (extended permissions - allowxperm range I) |
| 191 |
|
| 192 |
type test18_t; |
| 193 |
allow test18_t self : file ioctl; |
| 194 |
allowxperm test18_t self : file ioctl { 0x1100-0x1300 }; |
| 195 |
neverallowxperm test18_t self : file ioctl 0x1111; |
| 196 |
|
| 197 |
|
| 198 |
## Test 19 (extended permissions - allowxperm range II) |
| 199 |
|
| 200 |
type test19_t; |
| 201 |
allow test19_t self : file ioctl; |
| 202 |
allowxperm test19_t self : file ioctl 0x1111; |
| 203 |
neverallowxperm test19_t self : file ioctl { 0x1100-0x1300 }; |
| 204 |
|
| 205 |
|
| 206 |
## Test 20 (extended permissions - misc targets I) |
| 207 |
|
| 208 |
attribute test20_a; |
| 209 |
type test20_t, test20_a; |
| 210 |
|
| 211 |
allow test20_a test20_a : file ioctl; |
| 212 |
allowxperm test20_a test20_a : file ioctl 0x1111; |
| 213 |
neverallowxperm test20_a self : file ioctl 0x1111; |
| 214 |
|
| 215 |
|
| 216 |
## Test 21 (extended permissions - misc targets II) |
| 217 |
|
| 218 |
attribute test21_1_a; |
| 219 |
attribute test21_2_a; |
| 220 |
type test21_t, test21_1_a, test21_2_a; |
| 221 |
|
| 222 |
allow test21_1_a test21_1_a : file ioctl; |
| 223 |
allowxperm test21_1_a test21_2_a : file ioctl 0x1111; |
| 224 |
neverallowxperm test21_1_a self : file ioctl 0x1111; |
| 225 |
|
| 226 |
|
| 227 |
## Test 22 (extended permissions - misc targets III) |
| 228 |
|
| 229 |
attribute test22_a; |
| 230 |
type test22_t, test22_a; |
| 231 |
|
| 232 |
allow test22_a test22_a : file ioctl; |
| 233 |
allowxperm test22_t self : file ioctl 0x1111; |
| 234 |
neverallowxperm test22_a self : file ioctl 0x1111; |
| 235 |
|
| 236 |
|
| 237 |
## Test 23 (extended permissions - misc targets IV) |
| 238 |
|
| 239 |
attribute test23_a; |
| 240 |
type test23_t, test23_a; |
| 241 |
|
| 242 |
allow test23_a test23_a : file ioctl; |
| 243 |
allowxperm test23_t test23_t : file ioctl 0x1111; |
| 244 |
neverallowxperm test23_a self : file ioctl 0x1111; |
| 245 |
|
| 246 |
|
| 247 |
## Test 24 (extended permissions - misc targets V) |
| 248 |
|
| 249 |
attribute test24_a; |
| 250 |
type test24_t, test24_a; |
| 251 |
|
| 252 |
allow test24_a test24_a : file ioctl; |
| 253 |
allowxperm test24_t test24_a : file ioctl 0x1111; |
| 254 |
neverallowxperm test24_a self : file ioctl 0x1111; |
| 255 |
|
| 256 |
|
| 257 |
## Test 25 (extended permissions - misc targets VI) |
| 258 |
|
| 259 |
attribute test25_a; |
| 260 |
type test25_t, test25_a; |
| 261 |
|
| 262 |
allow test25_a test25_a : file ioctl; |
| 263 |
allowxperm test25_a self : file ioctl 0x1111; |
| 264 |
neverallowxperm test25_a self : file ioctl 0x1111; |
| 265 |
|
| 266 |
|
| 267 |
## Test 26 (extended permissions - assert twice) |
| 268 |
|
| 269 |
attribute test26_a; |
| 270 |
type test26_1_t, test26_a; |
| 271 |
type test26_2_t, test26_a; |
| 272 |
allow test26_a test26_a : file ioctl; |
| 273 |
allowxperm test26_a test26_a : file ioctl 0x1111; |
| 274 |
neverallowxperm test26_1_t test26_a : file ioctl 0x1111; |
| 275 |
|
| 276 |
|
| 277 |
######################################## |
| 278 |
# |
| 279 |
# Test End |
| 280 |
# |
| 281 |
######################################## |
| 282 |
|
| 283 |
|
| 284 |
type sys_isid; |
| 285 |
role sys_role; |
| 286 |
role sys_role types sys_isid; |
| 287 |
gen_user(sys_user,, sys_role, s0, s0 - s0:c0.c23) |
| 288 |
sid kernel gen_context(sys_user:sys_role:sys_isid, s0) |
| 289 |
sid security gen_context(sys_user:sys_role:sys_isid, s0) |
| 290 |
sid unlabeled gen_context(sys_user:sys_role:sys_isid, s0) |
| 291 |
sid file gen_context(sys_user:sys_role:sys_isid, s0) |
| 292 |
sid port gen_context(sys_user:sys_role:sys_isid, s0) |
| 293 |
sid netif gen_context(sys_user:sys_role:sys_isid, s0) |
| 294 |
sid netmsg gen_context(sys_user:sys_role:sys_isid, s0) |
| 295 |
sid node gen_context(sys_user:sys_role:sys_isid, s0) |
| 296 |
sid devnull gen_context(sys_user:sys_role:sys_isid, s0) |
| 297 |
fs_use_trans devpts gen_context(sys_user:sys_role:sys_isid, s0); |
| 298 |
fs_use_trans devtmpfs gen_context(sys_user:sys_role:sys_isid, s0); |