• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1(type bin_t)
2(type kernel_t)
3(type security_t)
4(type unlabeled_t)
5(handleunknown allow)
6(mls true)
7
8(policycap open_perms)
9
10(category c0)
11(category c1)
12(category c2)
13(category c3)
14(category c4)
15(category c5)
16(categoryalias cat0)
17(categoryaliasactual cat0 c0)
18(categoryset cats01 (c0 c1))
19(categoryset cats02 (c2 c3))
20(categoryset cats03 (range c0 c5))
21(categoryset cats04 (not (range c0 c2)))
22(categoryorder (cat0 c1 c2 c3))
23(categoryorder (c3 c4 c5))
24
25(sensitivity s0)
26(sensitivity s1)
27(sensitivity s2)
28(sensitivity s3)
29(sensitivityalias sens0)
30(sensitivityaliasactual sens0 s0)
31(sensitivityorder (s0 s1 s2 s3))
32
33(sensitivitycategory s0 (cats03))
34(sensitivitycategory s1 cats01)
35(sensitivitycategory s1 (c2))
36(sensitivitycategory s2 (cats01 cats02))
37(sensitivitycategory s2 (range c4 c5))
38(sensitivitycategory s3 (range c0 c5))
39
40(level low (s0))
41(level high (s3 (range c0 c3)))
42(levelrange low_high (low high))
43(levelrange lh1 ((s0 (c0)) (s2 (c0 c3))))
44(levelrange lh2 (low (s2 (c0 c3))))
45(levelrange lh3 ((s0 cats04) (s2 (range c0 c5))))
46(levelrange lh4 ((s0) (s1)))
47
48(block policy
49	(class file (execute_no_trans entrypoint execmod open audit_access a b c d e))
50	; order should be: file char b c a dir d e f
51	(classorder (file char))
52	(classorder (unordered dir))
53	(classorder (unordered c a b d e f))
54	(classorder (char b c a))
55
56	(common file (ioctl read write create getattr setattr lock relabelfrom
57			relabelto append unlink link rename execute swapon
58			quotaon mounton))
59	(classcommon file file)
60
61	(classpermission file_rw)
62	(classpermissionset file_rw (file (read write getattr setattr lock append)))
63
64	;;(classpermission loop1)
65	;;(classpermissionset loop1 ((loop2)))
66	;;(classpermission loop2)
67	;;(classpermissionset loop2 ((loop3)))
68	;;(classpermission loop3)
69	;;(classpermissionset loop3 ((loop1)))
70
71	(class char (foo))
72	(classcommon char file)
73
74	(class dir ())
75	(class a ())
76	(class b ())
77	(class c ())
78	(class d ())
79	(class e ())
80	(class f ())
81	(classcommon dir file)
82
83	(classpermission char_w)
84	(classpermissionset char_w (char (write setattr)))
85	(classpermissionset char_w (file (open read getattr)))
86
87	(classmap files (read))
88	(classmapping files read
89		(file (open read getattr)))
90	(classmapping files read
91		char_w)
92
93	(type auditadm_t)
94	(type console_t)
95	(type console_device_t)
96	(type user_tty_device_t)
97	(type device_t)
98	(type getty_t)
99	(type exec_t)
100	(type bad_t)
101
102	;;(allow console_t console_device_t file_rw)
103	(allow console_t console_device_t (files (read)))
104
105	(permissionx ioctl_test (ioctl files (and (range 0x1600 0x19FF) (not (range 0x1750 0x175F)))))
106	(allowx console_t console_device_t ioctl_test)
107
108	(boolean secure_mode false)
109	(boolean console_login true)
110
111	(sid kernel)
112	(sid security)
113	(sid unlabeled)
114	(sidorder (kernel security))
115	(sidorder (security unlabeled))
116
117	(typeattribute exec_type)
118	(typeattribute foo_type)
119	(typeattribute bar_type)
120	(typeattribute baz_type)
121	(typeattribute not_bad_type)
122	(typeattributeset exec_type (or bin_t kernel_t))
123	(typeattributeset foo_type (and exec_type kernel_t))
124	(typeattributeset bar_type (xor exec_type foo_type))
125	(typeattributeset baz_type (not bin_t))
126	(typeattributeset baz_type (and exec_type (and bar_type bin_t)))
127	(typeattributeset not_bad_type (not bad_t))
128	(typealias sbin_t)
129	(typealiasactual sbin_t bin_t)
130	(typepermissive device_t)
131	(typemember device_t bin_t file exec_t)
132	(typetransition device_t console_t files console_device_t)
133
134	(roleattribute exec_role)
135	(roleattribute foo_role)
136	(roleattribute bar_role)
137	(roleattribute baz_role)
138	(roleattribute foo_role_a)
139	(roleattributeset exec_role (or user_r system_r))
140	(roleattributeset foo_role_a (baz_r user_r system_r))
141	(roleattributeset foo_role (and exec_role system_r))
142	(roleattributeset bar_role (xor exec_role foo_role))
143	(roleattributeset baz_role (not user_r))
144
145	(rangetransition device_t console_t file low_high)
146	(rangetransition device_t kernel_t file ((s0) (s3 (not c3))))
147
148	(typetransition device_t console_t file "some_file" getty_t)
149
150	(allow foo_type self (file (execute)))
151	(allow bin_t device_t (file (execute)))
152
153	;; Next two rules violate the neverallow rule that follows
154	;;(allow bad_t not_bad_type (file (execute)))
155	;;(allow bad_t exec_t (file (execute)))
156	(neverallow bad_t not_bad_type (file (execute)))
157
158	(booleanif secure_mode
159		(true
160			(auditallow device_t exec_t (file (read write)))
161		)
162	)
163
164	(booleanif console_login
165		(true
166			(typechange auditadm_t console_device_t file user_tty_device_t)
167			(allow getty_t console_device_t (file (getattr open read write append)))
168		)
169		(false
170			(dontaudit getty_t console_device_t (file (getattr open read write append)))
171		)
172	)
173
174	(booleanif (not (xor (eq secure_mode console_login)
175				(and (or secure_mode console_login) secure_mode ) ) )
176		(true
177			(allow bin_t exec_t (file (execute)))
178		)
179	)
180
181	(tunable allow_execfile true)
182	(tunable allow_userexec false)
183
184	(tunableif (not (xor (eq allow_execfile allow_userexec)
185				(and (or allow_execfile allow_userexec)
186					(and allow_execfile allow_userexec) ) ) )
187		(true
188			(allow bin_t exec_t (file (execute)))
189		)
190	)
191
192	(optional allow_rules
193		(allow user_t exec_t (bins (execute)))
194	)
195
196	(dontaudit device_t auditadm_t (file (read)))
197	(auditallow device_t auditadm_t (file (open)))
198
199	(user system_u)
200	(user user_u)
201	(user foo_u)
202	(userprefix user_u user)
203	(userprefix system_u user)
204
205	(selinuxuser name user_u low_high)
206	(selinuxuserdefault user_u ((s0 (c0)) (s3 (range c0 c3))))
207
208	(role system_r)
209	(role user_r)
210	(role baz_r)
211
212	(roletype system_r bin_t)
213	(roletype system_r kernel_t)
214	(roletype system_r security_t)
215	(roletype system_r unlabeled_t)
216	(roletype system_r exec_type)
217	(roletype exec_role bin_t)
218	(roletype exec_role exec_type)
219	(roleallow system_r user_r)
220	(roletransition system_r bin_t file user_r)
221
222	(userrole foo_u foo_role)
223	(userlevel foo_u low)
224
225	(userattribute ua1)
226	(userattribute ua2)
227	(userattribute ua3)
228	(userattribute ua4)
229	(userattributeset ua1 (user_u system_u))
230	(userattributeset ua2 (foo_u system_u))
231	(userattributeset ua3 (and ua1 ua2))
232	(user u5)
233	(user u6)
234	(userlevel u5 low)
235	(userlevel u6 low)
236	(userrange u5 low_high)
237	(userrange u6 low_high)
238	(userattributeset ua4 (u5 u6))
239	(userrole ua4 foo_role_a)
240
241	(userrange foo_u low_high)
242
243	(userrole system_u system_r)
244	(userlevel system_u low)
245	(userrange system_u low_high)
246
247	(userrole user_u user_r)
248	(userlevel user_u (s0 (range c0 c2)))
249	(userrange user_u (low high))
250
251	(sidcontext kernel (system_u system_r kernel_t ((s0) high)))
252	(sidcontext security (system_u system_r security_t (low (s3 (range c0 c3)))))
253	(sidcontext unlabeled (system_u system_r unlabeled_t (low high)))
254
255	(context system_u_bin_t_l2h (system_u system_r bin_t (low high)))
256
257	(ipaddr ip_v4 192.25.35.200)
258	(ipaddr netmask 192.168.1.1)
259	(ipaddr ip_v6 2001:0DB8:AC10:FE01::)
260	(ipaddr netmask_v6 2001:0DE0:DA88:2222::)
261
262	(filecon "/usr/bin/foo" file system_u_bin_t_l2h)
263	(filecon "/usr/bin/bar" file (system_u system_r kernel_t (low low)))
264	(filecon "/usr/bin/baz" any ())
265	(filecon "/usr/bin/aaa" any (system_u system_r kernel_t ((s0) (s3 (range c0 c2)))))
266	(filecon "/usr/bin/bbb" any (system_u system_r kernel_t ((s0 (c0)) high)))
267	(filecon "/usr/bin/ccc" any (system_u system_r kernel_t (low (s3 (cats01)))))
268	(filecon "/usr/bin/ddd" any (system_u system_r kernel_t (low (s3 (cats01 cats02)))))
269	(nodecon ip_v4 netmask system_u_bin_t_l2h)
270	(nodecon ip_v6 netmask_v6 system_u_bin_t_l2h)
271	(portcon udp 25 system_u_bin_t_l2h)
272	(portcon tcp 22 system_u_bin_t_l2h)
273	(portcon dccp (2048 2096) system_u_bin_t_l2h)
274	(portcon sctp (1024 1035) system_u_bin_t_l2h)
275	(genfscon - "/usr/bin" system_u_bin_t_l2h)
276	(netifcon eth0 system_u_bin_t_l2h system_u_bin_t_l2h) ;different contexts?
277	(fsuse xattr ext3 system_u_bin_t_l2h)
278
279	; XEN
280	(pirqcon 256 system_u_bin_t_l2h)
281	(iomemcon (0 255) system_u_bin_t_l2h)
282	(ioportcon (22 22) system_u_bin_t_l2h)
283	(pcidevicecon 345 system_u_bin_t_l2h)
284	(devicetreecon "/this is/a/path" system_u_bin_t_l2h)
285
286	; InfiniBand
287	(ibpkeycon fe80:: (0 0x10) system_u_bin_t_l2h)
288	(ibpkeycon fe80::7629:afff:fe0f:8e5d (15 25) (system_u system_r kernel_t (low (s3 (cats01 cats02)))))
289	(ibendportcon mlx5_0 1 system_u_bin_t_l2h)
290	(ibendportcon mlx4_3 5 (system_u system_r kernel_t (low (s3 (cats01 cats02)))))
291
292	(constrain (files (read)) (not (or (and (eq t1 exec_t) (eq t2 bin_t)) (eq r1 r2))))
293	(constrain char_w (not (or (and (eq t1 exec_t) (eq t2 bin_t)) (eq r1 r2))))
294
295	(constrain (file (read)) (or (and (eq t1 exec_t) (neq t2 bin_t) ) (eq u1 ua4) ) )
296	(constrain (file (open)) (dom r1 r2))
297	(constrain (file (open)) (domby r1 r2))
298	(constrain (file (open)) (incomp r1 r2))
299
300	(validatetrans file (eq t1 exec_t))
301
302	(mlsconstrain (file (open)) (not (or (and (eq l1 l2) (eq u1 u2)) (eq r1 r2))))
303	(mlsconstrain (file (open)) (or (and (eq l1 l2) (eq u1 u2)) (neq r1 r2)))
304	(mlsconstrain (file (open)) (dom h1 l2))
305	(mlsconstrain (file (open)) (domby l1 h2))
306	(mlsconstrain (file (open)) (incomp l1 l2))
307
308	(mlsvalidatetrans file (domby l1 h2))
309
310	(macro test_mapping ((classpermission cps))
311	       (allow bin_t auditadm_t cps))
312
313	(call test_mapping ((file (read))))
314	(call test_mapping ((files (read))))
315	(call test_mapping (char_w))
316
317	(defaultuser (file char) source)
318	(defaultrole char target)
319	(defaulttype (files) source)
320	(defaultrange (file) target low)
321	(defaultrange (char) source low-high)
322)
323
324(macro all ((type x))
325	(allow x bin_t (policy.file (execute)))
326	(allowx x bin_t (ioctl policy.file (range 0x1000 0x11FF)))
327)
328(call all (bin_t))
329
330(block z
331    (block ba
332        (roletype r t)
333        (blockabstract z.ba)))
334
335(block test_ba
336    (blockinherit z.ba)
337    (role r)
338    (type t))
339
340(block bb
341	(type t1)
342	(type t2)
343	(boolean b1 false)
344	(tunable tun1 true)
345	(macro m ((boolean b))
346		(tunableif tun1
347			(true
348				(allow t1 t2 (policy.file (write))))
349			(false
350				(allow t1 t2 (policy.file (execute)))))
351		(booleanif b
352			(true
353				(allow t1 t2 (policy.file (read))))))
354
355	(call m (b1))
356)
357
358(in bb
359	(tunableif bb.tun1
360		(true
361			(allow bb.t2 bb.t1 (policy.file (read write execute))))))
362