Debian Codegraph @

tests/policies/test-neverallow/policy_not_self.conf

raw
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 class class5
11 class class6
12 class class7
13 class class17
14
15 sid kernel
16 sid security
17 sid unlabeled
18 sid file
19 sid port
20 sid netif
21 sid netmsg
22 sid node
23 sid devnull
24
25 class process { dyntransition transition }
26 class file { ioctl read write }
27
28 class class5 { perm }
29 class class6 { perm }
30 class class7 { perm }
31 class class17 { ioctl }
32
33 ifdef(`enable_mls',`
34 sensitivity s0;
35 dominance { s0 }
36 category c0; category c1; category c2; category c3;
37 category c4; category c5; category c6; category c7;
38 category c8; category c9; category c10; category c11;
39 category c12; category c13; category c14; category c15;
40 category c16; category c17; category c18; category c19;
41 category c20; category c21; category c22; category c23;
42
43 level s0:c0.c23;
44
45 mlsconstrain file { write } ( h1 dom h2 );
46 ')
47
48
49 ########################################
50 #
51 # Test start
52 #
53 ########################################
54
55
56 ## Test 1 (single type)
57
58 type test1_t;
59 allow test1_t test1_t : file read;
60 neverallow test1_t ~self : file read; # nofail
61
62
63 ## Test 2 (single type)
64
65 type test2_t;
66 allow test2_t self : file read;
67 neverallow test2_t ~self : file read; # nofail
68
69
70 ## Test 3 (single type)
71
72 type test3_1_t;
73 type test3_2_t;
74 allow test3_1_t test3_2_t : file read;
75 neverallow test3_1_t ~self : file read;
76
77
78 ## Test 4 (two types I)
79
80 type test4_1_t;
81 type test4_2_t;
82 allow { test4_1_t test4_2_t } { test4_1_t test4_2_t } : file read;
83 neverallow test4_1_t ~self : file read;
84
85
86 ## Test 5 (two types II)
87
88 type test5_1_t;
89 type test5_2_t;
90 allow { test5_1_t test5_2_t } { test5_1_t test5_2_t } : class5 perm;
91 neverallow * ~self : class5 perm;
92
93
94 ## Test 6 (two types III)
95
96 type test6_1_t;
97 type test6_2_t;
98 allow { test6_1_t test6_2_t } { test6_1_t test6_2_t } : class6 perm;
99 neverallow * ~{ self test6_1_t } : class6 perm;
100
101
102 ## Test 7 (two types IV)
103
104 type test7_1_t;
105 type test7_2_t;
106 allow { test7_1_t test7_2_t } { test7_1_t test7_2_t } : class7 perm;
107 neverallow * ~{ self test7_1_t test7_2_t } : class7 perm; # nofail
108
109
110 ## Test 8 (attribute violates type I)
111
112 attribute test8_a;
113 type test8_1_t, test8_a;
114 type test8_2_t, test8_a;
115 allow test8_a test8_a : file read;
116 neverallow test8_1_t ~self : file *;
117
118
119 ## Test 9 (attribute violates type II)
120
121 attribute test9_a;
122 type test9_1_t, test9_a;
123 type test9_2_t, test9_a;
124 allow test9_1_t test9_a : file read;
125 neverallow test9_1_t ~self : file *;
126
127
128 ## Test 10 (attribute violates type III)
129
130 attribute test10_1_a;
131 attribute test10_2_a;
132 type test10_1_t, test10_1_a, test10_1_a;
133 type test10_2_t, test10_1_a, test10_1_a;
134 allow test10_1_a test10_1_a : file read;
135 neverallow test10_1_t ~self : file *;
136
137
138 ## Test 11 (attribute violates attribute I)
139
140 attribute test11_1_a;
141 attribute test11_2_a;
142 type test11_1_t, test11_1_a, test11_2_a;
143 type test11_2_t, test11_1_a, test11_2_a;
144 allow test11_1_t self : file read;
145 allow test11_2_t test11_2_t : file read;
146 neverallow test11_1_a ~self : file *; # nofail
147
148
149 ## Test 12 (attribute violates attribute II)
150
151 attribute test12_a;
152 type test12_1_t, test12_a;
153 type test12_2_t, test12_a;
154 allow test12_1_t test12_2_t : file read;
155 neverallow test12_a ~self : file *;
156
157
158 ## Test 13 (attribute violates attribute III)
159
160 attribute test13_a;
161 type test13_1_t, test13_a;
162 type test13_2_t, test13_a;
163 allow test13_1_t test13_a : file read;
164 neverallow test13_a ~self : file *;
165
166
167 ## Test 14 (attribute violates attribute IV)
168
169 attribute test14_a;
170 type test14_1_t, test14_a;
171 type test14_2_t, test14_a;
172 allow test14_a test14_a : file read;
173 neverallow test14_a ~self : file *;
174
175
176 ## Test 15 (attribute violates attribute V)
177
178 attribute test13_1_a;
179 attribute test13_2_a;
180 type test13_t, test13_1_a, test13_2_a;
181 allow test13_1_a test13_2_a : file read;
182 neverallow test13_a ~self : file *;
183
184
185 ## Test 16 (types violate attribute)
186
187 attribute test16_a;
188 type test16_1_t, test16_a;
189 type test16_2_t, test16_a;
190 allow { test16_1_t test16_2_t } { test16_1_t test16_2_t } : file read;
191 neverallow test16_a ~self : file ~write;
192
193
194 ## Test 17 (extended permissions I)
195
196 type test17_1_t;
197 type test17_2_t;
198 allow { test17_1_t test17_2_t } { test17_1_t test17_2_t } : class17 ioctl;
199 neverallowxperm ~test17_2_t ~self : class17 ioctl 0x1111;
200
201
202 ## Test 18 (extended permissions II)
203
204 type test18_1_t;
205 type test18_2_t;
206 allow { test18_1_t test18_2_t } { test18_1_t test18_2_t } : file ioctl;
207 allowxperm { test18_1_t test18_2_t } { test18_1_t test18_2_t } : file ioctl 0x1111;
208 neverallowxperm test18_1_t ~self : file ioctl 0x2222; # nofail
209
210
211 ## Test 19 (extended permissions III)
212
213 type test19_1_t;
214 type test19_2_t;
215 allow { test19_1_t test19_2_t } { test19_1_t test19_2_t } : file ioctl;
216 allowxperm { test19_1_t test19_2_t } { test19_1_t test19_2_t } : file ioctl { 0x0100 - 0x0102 };
217 neverallowxperm test19_2_t ~self : file ioctl { 0x0101 - 0x0104 };
218
219
220 ## Test 20 (extended permissions IV)
221
222 type test20_1_t;
223 type test20_2_t;
224 allow { test20_1_t test20_2_t } { test20_1_t test20_2_t } : file ioctl;
225 allowxperm test20_1_t test20_1_t : file ioctl 0x0101;
226 allowxperm test20_1_t test20_2_t : file ioctl 0x0102;
227 allowxperm test20_2_t test20_1_t : file ioctl 0x0103;
228 allowxperm test20_2_t test20_2_t : file ioctl 0x0104;
229 neverallowxperm { test20_1_t test20_2_t } ~self : file ioctl { 0x0000 - 0x9000 };
230
231
232 ## Test 21 (extended permissions V)
233
234 attribute test21_a;
235 type test21_1_t, test21_a;
236 type test21_2_t, test21_a;
237 allow test21_a test21_a : file ioctl;
238 allowxperm test21_a test21_a : file ioctl 0x9501;
239 neverallowxperm test21_1_t ~self : file ioctl 0x9511; # nofail
240
241
242 ## Test 22 (extended permissions VI)
243
244 type test22_t;
245 allow test22_t self : file ioctl;
246 allowxperm test22_t self : file ioctl 0x9501;
247 allowxperm test22_t self : file ioctl 0x9511;
248 neverallowxperm test22_t ~self : file ioctl 0x9511; # nofail
249
250
251 ## Test 23 (extended permissions VII)
252
253 attribute test23_a;
254 type test23_1_t, test23_a;
255 type test23_2_t, test23_a;
256 allow test23_a test23_a : file ioctl;
257 allowxperm test23_a test23_a : file ioctl 0x9501;
258 allowxperm test23_1_t test23_2_t : file ioctl 0x9511;
259 neverallowxperm test23_1_t ~self : file ioctl 0x9511;
260
261
262 ## Test 24 (extended permissions VII)
263
264 attribute test24_a;
265 type test24_1_t, test24_a;
266 type test24_2_t, test24_a;
267 allow test24_a test24_a : file ioctl;
268 allowxperm test24_a test24_a : file ioctl 0x9501;
269 allowxperm test24_1_t test24_a : file ioctl 0x9511;
270 neverallowxperm test24_1_t ~self : file ioctl 0x9511;
271
272
273 ## Test 25 (extended permissions IX)
274
275 attribute test25_a;
276 type test25_1_t, test25_a;
277 type test25_2_t, test25_a;
278 allow test25_a test25_a : file ioctl;
279 allowxperm test25_a test25_a : file ioctl 0x9501;
280 allowxperm test25_a test25_a : file ioctl 0x9511;
281 neverallowxperm test25_1_t ~self : file ioctl 0x9511;
282
283
284 ## Test 26 (extended permissions X)
285
286 attribute test26_1_a;
287 attribute test26_2_a;
288 type test26_1_t, test26_1_a, test26_2_a;
289 type test26_2_t, test26_1_a, test26_2_a;
290 allow { test26_1_a test26_2_a } { test26_1_a test26_2_a } : file ioctl;
291 allowxperm { test26_1_a test26_2_a } { test26_1_a test26_2_a } : file ioctl 0x9501;
292 allowxperm test26_1_a test26_2_a : file ioctl 0x9511;
293 neverallowxperm test26_1_t ~self : file ioctl 0x9511;
294
295
296 ## Test 27 (extended permissions attribute violation I)
297
298 attribute test27_a;
299 type test27_1_t, test27_a;
300 type test27_2_t, test27_a;
301 allow test27_a test27_a : file ioctl;
302 allowxperm test27_a test27_a : file ioctl 0x9501;
303 allowxperm test27_1_t self : file ioctl 0x9521;
304 allowxperm test27_2_t test27_2_t : file ioctl 0x9521;
305 neverallowxperm test27_a ~self : file ioctl 0x9521; # nofail
306
307
308 ## Test 28 (extended permissions attribute violation II)
309
310 attribute test28_a;
311 type test28_1_t, test28_a;
312 type test28_2_t, test28_a;
313 allow test28_a test28_a : file ioctl;
314 allowxperm test28_1_t test28_2_t : file ioctl 0x9521;
315 neverallowxperm test28_a ~self : file ioctl 0x9521;
316
317
318 ## Test 29 (extended permissions attribute violation III)
319
320 attribute test29_a;
321 type test29_1_t, test29_a;
322 type test29_2_t, test29_a;
323 allow test29_a test29_a : file ioctl;
324 allowxperm test29_1_t test29_a : file ioctl 0x9521;
325 neverallowxperm test29_a ~self : file ioctl 0x9521;
326
327
328 ## Test 30 (extended permissions attribute violation IV)
329
330 attribute test30_a;
331 type test30_1_t, test30_a;
332 type test30_2_t, test30_a;
333 allow test30_a test30_a : file ioctl;
334 allowxperm test30_a test30_a : file ioctl 0x9521;
335 neverallowxperm test30_a ~self : file ioctl 0x9521;
336
337
338 ## Test 31 (extended permissions attribute violation V)
339
340 attribute test31_1_a;
341 attribute test31_2_a;
342 type test31_1_t, test31_1_a, test31_2_a;
343 type test31_2_t, test31_1_a, test31_2_a;
344 allow test31_1_a test31_1_a : file ioctl;
345 allowxperm test31_1_a test31_2_a : file ioctl 0x9521;
346 neverallowxperm test31_1_a ~self : file ioctl 0x9521;
347
348
349 ########################################
350 #
351 # Test End
352 #
353 ########################################
354
355
356 type sys_isid;
357 role sys_role;
358 role sys_role types sys_isid;
359 gen_user(sys_user,, sys_role, s0, s0 - s0:c0.c23)
360 sid kernel gen_context(sys_user:sys_role:sys_isid, s0)
361 sid security gen_context(sys_user:sys_role:sys_isid, s0)
362 sid unlabeled gen_context(sys_user:sys_role:sys_isid, s0)
363 sid file gen_context(sys_user:sys_role:sys_isid, s0)
364 sid port gen_context(sys_user:sys_role:sys_isid, s0)
365 sid netif gen_context(sys_user:sys_role:sys_isid, s0)
366 sid netmsg gen_context(sys_user:sys_role:sys_isid, s0)
367 sid node gen_context(sys_user:sys_role:sys_isid, s0)
368 sid devnull gen_context(sys_user:sys_role:sys_isid, s0)
369 fs_use_trans devpts gen_context(sys_user:sys_role:sys_isid, s0);
370 fs_use_trans devtmpfs gen_context(sys_user:sys_role:sys_isid, s0);