Debian Codegraph @

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