1 |
commit: f120e886dbba68a31eba791831db34da7ad88518 |
2 |
Author: Dominick Grift <dominick.grift <AT> gmail <DOT> com> |
3 |
AuthorDate: Sun Sep 30 15:54:15 2012 +0000 |
4 |
Commit: Sven Vermeulen <sven.vermeulen <AT> siphos <DOT> be> |
5 |
CommitDate: Tue Oct 2 18:05:27 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-refpolicy.git;a=commit;h=f120e886 |
7 |
|
8 |
Changes to the cron policy module |
9 |
|
10 |
Make cron userdomain transition work |
11 |
|
12 |
Signed-off-by: Dominick Grift <dominick.grift <AT> gmail.com> |
13 |
|
14 |
--- |
15 |
policy/modules/contrib/cron.if | 113 +++++++++++++++++++++++++++++++++++----- |
16 |
policy/modules/contrib/cron.te | 60 ++++++++++++--------- |
17 |
2 files changed, 133 insertions(+), 40 deletions(-) |
18 |
|
19 |
diff --git a/policy/modules/contrib/cron.if b/policy/modules/contrib/cron.if |
20 |
index ddc323e..384fda7 100644 |
21 |
--- a/policy/modules/contrib/cron.if |
22 |
+++ b/policy/modules/contrib/cron.if |
23 |
@@ -42,7 +42,7 @@ template(`cron_common_crontab_template',` |
24 |
|
25 |
######################################## |
26 |
## <summary> |
27 |
-## Role access for cron |
28 |
+## Role access for cron. |
29 |
## </summary> |
30 |
## <param name="role"> |
31 |
## <summary> |
32 |
@@ -60,6 +60,7 @@ interface(`cron_role',` |
33 |
gen_require(` |
34 |
type cronjob_t, crontab_t, crontab_exec_t; |
35 |
type user_cron_spool_t, crond_t; |
36 |
+ bool cron_userdomain_transition; |
37 |
') |
38 |
|
39 |
############################## |
40 |
@@ -82,14 +83,32 @@ interface(`cron_role',` |
41 |
allow $2 user_cron_spool_t:file { getattr read write ioctl }; |
42 |
|
43 |
allow $2 crontab_t:process { ptrace signal_perms }; |
44 |
- ps_process_pattern($2, { cronjob_t crontab_t }) |
45 |
+ ps_process_pattern($2, crontab_t) |
46 |
|
47 |
corecmd_exec_bin(crontab_t) |
48 |
corecmd_exec_shell(crontab_t) |
49 |
|
50 |
tunable_policy(`cron_userdomain_transition',` |
51 |
allow crond_t $2:process transition; |
52 |
+ allow crond_t $2:fd use; |
53 |
+ allow crond_t $2:key manage_key_perms; |
54 |
+ |
55 |
allow $2 user_cron_spool_t:file entrypoint; |
56 |
+ |
57 |
+ allow $2 crond_t:fifo_file rw_fifo_file_perms; |
58 |
+ |
59 |
+ allow $2 cronjob_t:process { ptrace signal_perms }; |
60 |
+ ps_process_pattern($2, cronjob_t) |
61 |
+ ',` |
62 |
+ dontaudit crond_t $2:process transition; |
63 |
+ dontaudit crond_t $2:fd use; |
64 |
+ dontaudit crond_t $2:key manage_key_perms; |
65 |
+ |
66 |
+ dontaudit $2 user_cron_spool_t:file entrypoint; |
67 |
+ |
68 |
+ dontaudit $2 crond_t:fifo_file rw_fifo_file_perms; |
69 |
+ |
70 |
+ dontaudit $2 cronjob_t:process { ptrace signal_perms }; |
71 |
') |
72 |
|
73 |
optional_policy(` |
74 |
@@ -105,22 +124,24 @@ interface(`cron_role',` |
75 |
|
76 |
######################################## |
77 |
## <summary> |
78 |
-## Role access for unconfined cronjobs |
79 |
+## Role access for unconfined cron. |
80 |
## </summary> |
81 |
## <param name="role"> |
82 |
## <summary> |
83 |
-## Role allowed access |
84 |
+## Role allowed access. |
85 |
## </summary> |
86 |
## </param> |
87 |
## <param name="domain"> |
88 |
## <summary> |
89 |
-## User domain for the role |
90 |
+## User domain for the role. |
91 |
## </summary> |
92 |
## </param> |
93 |
# |
94 |
interface(`cron_unconfined_role',` |
95 |
gen_require(` |
96 |
type unconfined_cronjob_t, crontab_t, crontab_exec_t; |
97 |
+ type crond_t, user_cron_spool_t; |
98 |
+ bool cron_userdomain_transition; |
99 |
') |
100 |
|
101 |
############################## |
102 |
@@ -135,9 +156,12 @@ interface(`cron_unconfined_role',` |
103 |
# Local policy |
104 |
# |
105 |
|
106 |
- ps_process_pattern($2, unconfined_cronjob_t) |
107 |
+ domtrans_pattern($2, crontab_exec_t, crontab_t) |
108 |
|
109 |
- # domtrans_pattern($2, crontab_exec_t, crontab_t) |
110 |
+ dontaudit crond_t $2:process { noatsecure siginh rlimitinh }; |
111 |
+ allow $2 crond_t:process sigchld; |
112 |
+ |
113 |
+ allow $2 user_cron_spool_t:file { getattr read write ioctl }; |
114 |
|
115 |
allow $2 crontab_t:process { ptrace signal_perms }; |
116 |
ps_process_pattern($2, crontab_t) |
117 |
@@ -145,6 +169,29 @@ interface(`cron_unconfined_role',` |
118 |
corecmd_exec_bin(crontab_t) |
119 |
corecmd_exec_shell(crontab_t) |
120 |
|
121 |
+ tunable_policy(`cron_userdomain_transition',` |
122 |
+ allow crond_t $2:process transition; |
123 |
+ allow crond_t $2:fd use; |
124 |
+ allow crond_t $2:key manage_key_perms; |
125 |
+ |
126 |
+ allow $2 user_cron_spool_t:file entrypoint; |
127 |
+ |
128 |
+ allow $2 crond_t:fifo_file rw_fifo_file_perms; |
129 |
+ |
130 |
+ allow $2 unconfined_cronjob_t:process { ptrace signal_perms }; |
131 |
+ ps_process_pattern($2, unconfined_cronjob_t) |
132 |
+ ',` |
133 |
+ dontaudit crond_t $2:process transition; |
134 |
+ dontaudit crond_t $2:fd use; |
135 |
+ dontaudit crond_t $2:key manage_key_perms; |
136 |
+ |
137 |
+ dontaudit $2 user_cron_spool_t:file entrypoint; |
138 |
+ |
139 |
+ dontaudit $2 crond_t:fifo_file rw_fifo_file_perms; |
140 |
+ |
141 |
+ dontaudit $2 unconfined_cronjob_t:process { ptrace signal_perms }; |
142 |
+') |
143 |
+ |
144 |
optional_policy(` |
145 |
gen_require(` |
146 |
class dbus send_msg; |
147 |
@@ -158,16 +205,16 @@ interface(`cron_unconfined_role',` |
148 |
|
149 |
######################################## |
150 |
## <summary> |
151 |
-## Role access for cron |
152 |
+## Role access for admin cron. |
153 |
## </summary> |
154 |
## <param name="role"> |
155 |
## <summary> |
156 |
-## Role allowed access |
157 |
+## Role allowed access. |
158 |
## </summary> |
159 |
## </param> |
160 |
## <param name="domain"> |
161 |
## <summary> |
162 |
-## User domain for the role |
163 |
+## User domain for the role. |
164 |
## </summary> |
165 |
## </param> |
166 |
# |
167 |
@@ -175,23 +222,61 @@ interface(`cron_admin_role',` |
168 |
gen_require(` |
169 |
type cronjob_t, crontab_exec_t, admin_crontab_t; |
170 |
class passwd crontab; |
171 |
+ type crond_t, user_cron_spool_t; |
172 |
+ bool cron_userdomain_transition; |
173 |
') |
174 |
|
175 |
- role $1 types { cronjob_t admin_crontab_t }; |
176 |
+ ############################## |
177 |
+ # |
178 |
+ # Declarations |
179 |
+ # |
180 |
|
181 |
- ps_process_pattern($2, cronjob_t) |
182 |
+ role $1 types { cronjob_t admin_crontab_t }; |
183 |
|
184 |
- # Manipulate other users crontab. |
185 |
- allow $2 self:passwd crontab; |
186 |
+ ############################## |
187 |
+ # |
188 |
+ # Local policy |
189 |
+ # |
190 |
|
191 |
domtrans_pattern($2, crontab_exec_t, admin_crontab_t) |
192 |
|
193 |
+ dontaudit crond_t $2:process { noatsecure siginh rlimitinh }; |
194 |
+ allow $2 crond_t:process sigchld; |
195 |
+ |
196 |
+ allow $2 user_cron_spool_t:file { getattr read write ioctl }; |
197 |
+ |
198 |
allow $2 admin_crontab_t:process { ptrace signal_perms }; |
199 |
ps_process_pattern($2, admin_crontab_t) |
200 |
|
201 |
+ # Manipulate other users crontab. |
202 |
+ allow $2 self:passwd crontab; |
203 |
+ |
204 |
corecmd_exec_bin(admin_crontab_t) |
205 |
corecmd_exec_shell(admin_crontab_t) |
206 |
|
207 |
+ tunable_policy(`cron_userdomain_transition',` |
208 |
+ allow crond_t $2:process transition; |
209 |
+ allow crond_t $2:fd use; |
210 |
+ allow crond_t $2:key manage_key_perms; |
211 |
+ |
212 |
+ allow $2 user_cron_spool_t:file entrypoint; |
213 |
+ |
214 |
+ allow $2 crond_t:fifo_file rw_fifo_file_perms; |
215 |
+ |
216 |
+ allow $2 cronjob_t:process { ptrace signal_perms }; |
217 |
+ ps_process_pattern($2, cronjob_t) |
218 |
+ ',` |
219 |
+ dontaudit crond_t $2:process transition; |
220 |
+ dontaudit crond_t $2:fd use; |
221 |
+ dontaudit crond_t $2:key manage_key_perms; |
222 |
+ |
223 |
+ dontaudit $2 user_cron_spool_t:file entrypoint; |
224 |
+ |
225 |
+ dontaudit $2 crond_t:fifo_file rw_fifo_file_perms; |
226 |
+ |
227 |
+ dontaudit $2 cronjob_t:process { ptrace signal_perms }; |
228 |
+') |
229 |
+ |
230 |
optional_policy(` |
231 |
gen_require(` |
232 |
class dbus send_msg; |
233 |
|
234 |
diff --git a/policy/modules/contrib/cron.te b/policy/modules/contrib/cron.te |
235 |
index 412d5fb..1ae7194 100644 |
236 |
--- a/policy/modules/contrib/cron.te |
237 |
+++ b/policy/modules/contrib/cron.te |
238 |
@@ -1,4 +1,4 @@ |
239 |
-policy_module(cron, 2.5.0) |
240 |
+policy_module(cron, 2.5.1) |
241 |
|
242 |
gen_require(` |
243 |
class passwd rootok; |
244 |
@@ -132,7 +132,7 @@ ifdef(`enable_mcs',` |
245 |
|
246 |
############################## |
247 |
# |
248 |
-# Common local policy |
249 |
+# Common crontab local policy |
250 |
# |
251 |
|
252 |
allow crontab_domain self:capability { fowner setuid setgid chown dac_override }; |
253 |
@@ -154,7 +154,7 @@ selinux_dontaudit_search_fs(crontab_domain) |
254 |
files_list_spool(crontab_domain) |
255 |
files_read_etc_files(crontab_domain) |
256 |
files_read_usr_files(crontab_domain) |
257 |
-files_dontaudit_search_pids(crontab_domain) |
258 |
+files_search_pids(crontab_domain) |
259 |
|
260 |
fs_getattr_xattr_fs(crontab_domain) |
261 |
fs_manage_cgroup_dirs(crontab_domain) |
262 |
@@ -168,6 +168,7 @@ auth_rw_var_auth(crontab_domain) |
263 |
|
264 |
logging_send_syslog_msg(crontab_domain) |
265 |
logging_send_audit_msgs(crontab_domain) |
266 |
+logging_set_loginuid(crontab_domain) |
267 |
|
268 |
init_dontaudit_write_utmp(crontab_domain) |
269 |
init_read_utmp(crontab_domain) |
270 |
@@ -183,10 +184,6 @@ userdom_use_user_terminals(crontab_domain) |
271 |
userdom_read_user_home_content_files(crontab_domain) |
272 |
userdom_read_user_home_content_symlinks(crontab_domain) |
273 |
|
274 |
-tunable_policy(`cron_userdomain_transition',` |
275 |
- logging_set_loginuid(crontab_domain) |
276 |
-') |
277 |
- |
278 |
tunable_policy(`fcron_crond',` |
279 |
dontaudit crontab_domain crond_t:process signal; |
280 |
') |
281 |
@@ -250,9 +247,10 @@ read_files_pattern(crond_t, user_cron_spool_t, user_cron_spool_t) |
282 |
read_lnk_files_pattern(crond_t, user_cron_spool_t, user_cron_spool_t) |
283 |
allow crond_t user_cron_spool_t:file manage_lnk_file_perms; |
284 |
|
285 |
-allow crond_t { cronjob_t system_cronjob_t unconfined_cronjob_t }:process transition; |
286 |
-allow crond_t { cronjob_t system_cronjob_t unconfined_cronjob_t }:fd use; |
287 |
-allow crond_t { cronjob_t system_cronjob_t unconfined_cronjob_t }:key manage_key_perms; |
288 |
+allow crond_t system_cronjob_t:process transition; |
289 |
+allow crond_t system_cronjob_t:fd use; |
290 |
+allow crond_t system_cronjob_t:key manage_key_perms; |
291 |
+ |
292 |
dontaudit crond_t { cronjob_t system_cronjob_t unconfined_cronjob_t }:process { noatsecure siginh rlimitinh }; |
293 |
|
294 |
domtrans_pattern(crond_t, anacron_exec_t, system_cronjob_t) |
295 |
@@ -286,7 +284,6 @@ files_search_var_lib(crond_t) |
296 |
files_search_default(crond_t) |
297 |
|
298 |
mls_fd_share_all_levels(crond_t) |
299 |
-# crontab -e and kernel check of transition |
300 |
mls_file_read_all_levels(crond_t) |
301 |
mls_file_write_all_levels(crond_t) |
302 |
mls_process_set_level(crond_t) |
303 |
@@ -316,16 +313,24 @@ seutil_read_default_contexts(crond_t) |
304 |
|
305 |
miscfiles_read_localization(crond_t) |
306 |
|
307 |
-userdom_use_unpriv_users_fds(crond_t) |
308 |
userdom_list_user_home_dirs(crond_t) |
309 |
|
310 |
mta_send_mail(crond_t) |
311 |
|
312 |
+tunable_policy(`cron_userdomain_transition',` |
313 |
+ dontaudit crond_t { cronjob_t unconfined_cronjob_t }:process transition; |
314 |
+ dontaudit crond_t { cronjob_t unconfined_cronjob_t }:fd use; |
315 |
+ dontaudit crond_t { cronjob_t unconfined_cronjob_t }:key manage_key_perms; |
316 |
+',` |
317 |
+ allow crond_t { cronjob_t unconfined_cronjob_t }:process transition; |
318 |
+ allow crond_t { cronjob_t unconfined_cronjob_t }:fd use; |
319 |
+ allow crond_t { cronjob_t unconfined_cronjob_t }:key manage_key_perms; |
320 |
+') |
321 |
+ |
322 |
ifdef(`distro_debian',` |
323 |
allow crond_t self:process setrlimit; |
324 |
|
325 |
optional_policy(` |
326 |
- # Debian logcheck has the home dir set to its cache |
327 |
logwatch_search_cache_dir(crond_t) |
328 |
') |
329 |
') |
330 |
@@ -340,8 +345,8 @@ tunable_policy(`allow_polyinstantiation',` |
331 |
files_polyinstantiate_all(crond_t) |
332 |
') |
333 |
|
334 |
-tunable_policy(`fcron_crond', ` |
335 |
- allow crond_t system_cron_spool_t:file manage_file_perms; |
336 |
+tunable_policy(`fcron_crond',` |
337 |
+ allow crond_t { system_cron_spool_t user_cron_spool_t }:file manage_file_perms; |
338 |
') |
339 |
|
340 |
optional_policy(` |
341 |
@@ -461,7 +466,7 @@ files_search_var_lib(system_cronjob_t) |
342 |
manage_files_pattern(system_cronjob_t, system_cronjob_var_lib_t, system_cronjob_var_lib_t) |
343 |
|
344 |
allow system_cronjob_t crond_t:fd use; |
345 |
-allow system_cronjob_t crond_t:fifo_file rw_file_perms; |
346 |
+allow system_cronjob_t crond_t:fifo_file rw_fifo_file_perms; |
347 |
allow system_cronjob_t crond_t:process sigchld; |
348 |
|
349 |
allow system_cronjob_t cron_spool_t:dir list_dir_perms; |
350 |
@@ -623,7 +628,7 @@ optional_policy(` |
351 |
|
352 |
optional_policy(` |
353 |
postfix_read_config(system_cronjob_t) |
354 |
-') |
355 |
+') |
356 |
|
357 |
optional_policy(` |
358 |
prelink_delete_cache(system_cronjob_t) |
359 |
@@ -664,13 +669,6 @@ allow cronjob_t self:fifo_file rw_fifo_file_perms; |
360 |
allow cronjob_t self:unix_stream_socket create_stream_socket_perms; |
361 |
allow cronjob_t self:unix_dgram_socket create_socket_perms; |
362 |
|
363 |
-allow cronjob_t user_cron_spool_t:file entrypoint; |
364 |
- |
365 |
-#allow crond_t cronjob_t:key create; |
366 |
-allow cronjob_t crond_t:fd use; |
367 |
-allow cronjob_t crond_t:fifo_file rw_file_perms; |
368 |
-allow cronjob_t crond_t:process sigchld; |
369 |
- |
370 |
kernel_read_system_state(cronjob_t) |
371 |
kernel_read_kernel_sysctls(cronjob_t) |
372 |
|
373 |
@@ -723,8 +721,18 @@ userdom_manage_user_home_content_symlinks(cronjob_t) |
374 |
userdom_manage_user_home_content_pipes(cronjob_t) |
375 |
userdom_manage_user_home_content_sockets(cronjob_t) |
376 |
|
377 |
-tunable_policy(`fcron_crond',` |
378 |
- allow crond_t user_cron_spool_t:file manage_file_perms; |
379 |
+tunable_policy(`cron_userdomain_transition',` |
380 |
+ dontaudit cronjob_t crond_t:fd use; |
381 |
+ dontaudit cronjob_t crond_t:fifo_file rw_fifo_file_perms; |
382 |
+ dontaudit cronjob_t crond_t:process sigchld; |
383 |
+ |
384 |
+ dontaudit cronjob_t user_cron_spool_t:file entrypoint; |
385 |
+',` |
386 |
+ allow cronjob_t crond_t:fd use; |
387 |
+ allow cronjob_t crond_t:fifo_file rw_fifo_file_perms; |
388 |
+ allow cronjob_t crond_t:process sigchld; |
389 |
+ |
390 |
+ allow cronjob_t user_cron_spool_t:file entrypoint; |
391 |
') |
392 |
|
393 |
optional_policy(` |