aboutsummaryrefslogtreecommitdiff
blob: c4d18e894b7a0235de3e82478b4f21e783976ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
policy_module(xen, 1.11.0)

########################################
#
# Declarations
#

## <desc>
## <p>
## Allow xend to run blktapctrl/tapdisk.
## Not required if using dedicated logical volumes for disk images.
## </p>
## </desc>
gen_tunable(xend_run_blktap, true)

## <desc>
## <p>
## Allow xend to run qemu-dm.
## Not required if using paravirt and no vfb.
## </p>
## </desc>
gen_tunable(xend_run_qemu, true)

## <desc>
## <p>
## Allow xen to manage nfs files
## </p>
## </desc>
gen_tunable(xen_use_nfs, false)

type blktap_t;
type blktap_exec_t;
domain_type(blktap_t)
domain_entry_file(blktap_t, blktap_exec_t)
role system_r types blktap_t;

type blktap_var_run_t;
files_pid_file(blktap_var_run_t)

type evtchnd_t;
type evtchnd_exec_t;
init_daemon_domain(evtchnd_t, evtchnd_exec_t)

# log files
type evtchnd_var_log_t;
logging_log_file(evtchnd_var_log_t)

# pid files
type evtchnd_var_run_t;
files_pid_file(evtchnd_var_run_t)

type qemu_dm_t;
type qemu_dm_exec_t;
domain_type(qemu_dm_t)
domain_entry_file(qemu_dm_t, qemu_dm_exec_t)
role system_r types qemu_dm_t;

# console ptys
type xen_devpts_t;
term_pty(xen_devpts_t)
files_type(xen_devpts_t)

# Xen Image files
type xen_image_t; # customizable
files_type(xen_image_t)
# xen_image_t can be assigned to blk devices
dev_node(xen_image_t)

type xenctl_t;
files_type(xenctl_t)

type xend_t;
type xend_exec_t;
domain_type(xend_t)
init_daemon_domain(xend_t, xend_exec_t)

# tmp files
type xend_tmp_t;
files_tmp_file(xend_tmp_t)

# var/lib files
type xend_var_lib_t;
files_type(xend_var_lib_t)
# for mounting an NFS store
files_mountpoint(xend_var_lib_t)

# log files
type xend_var_log_t;
logging_log_file(xend_var_log_t)

# pid files
type xend_var_run_t;
files_pid_file(xend_var_run_t)
files_mountpoint(xend_var_run_t)

type xenstored_t;
type xenstored_exec_t;
init_daemon_domain(xenstored_t, xenstored_exec_t)

type xenstored_tmp_t;
files_tmp_file(xenstored_tmp_t)

# var/lib files
type xenstored_var_lib_t;
files_type(xenstored_var_lib_t)
files_mountpoint(xenstored_var_lib_t)

# log files
type xenstored_var_log_t;
logging_log_file(xenstored_var_log_t)

# pid files
type xenstored_var_run_t;
files_pid_file(xenstored_var_run_t)

type xenconsoled_t;
type xenconsoled_exec_t;
init_daemon_domain(xenconsoled_t, xenconsoled_exec_t)

# pid files
type xenconsoled_var_run_t;
files_pid_file(xenconsoled_var_run_t)

type xm_t;
type xm_exec_t;
domain_type(xm_t)
init_system_domain(xm_t, xm_exec_t)

########################################
#
# blktap local policy
#
# Do we need to allow execution of blktap?
tunable_policy(`xend_run_blktap',`
        # If yes, transition to its own domain.
	domtrans_pattern(xend_t, blktap_exec_t, blktap_t)

	allow blktap_t self:fifo_file { read write };

	dev_read_sysfs(blktap_t)
	dev_rw_xen(blktap_t)

	files_read_etc_files(blktap_t)

	logging_send_syslog_msg(blktap_t)

	miscfiles_read_localization(blktap_t)

	xen_stream_connect_xenstore(blktap_t)
',`
        # If no, then silently refuse to run it.
	dontaudit xend_t blktap_exec_t:file { execute execute_no_trans };
')

#######################################
#
# evtchnd local policy
#

manage_dirs_pattern(evtchnd_t, evtchnd_var_log_t, evtchnd_var_log_t)
manage_files_pattern(evtchnd_t, evtchnd_var_log_t, evtchnd_var_log_t)
logging_log_filetrans(evtchnd_t, evtchnd_var_log_t, { file dir })

manage_dirs_pattern(evtchnd_t, evtchnd_var_run_t, evtchnd_var_run_t)
manage_files_pattern(evtchnd_t, evtchnd_var_run_t, evtchnd_var_run_t)
manage_sock_files_pattern(evtchnd_t, evtchnd_var_run_t, evtchnd_var_run_t)
files_pid_filetrans(evtchnd_t, evtchnd_var_run_t, { file sock_file dir })

########################################
#
# qemu-dm local policy
#
# Do we need to allow execution of qemu-dm?
tunable_policy(`xend_run_qemu',`
	allow qemu_dm_t self:capability sys_resource;
	allow qemu_dm_t self:process setrlimit;
	allow qemu_dm_t self:fifo_file { read write };
	allow qemu_dm_t self:tcp_socket create_stream_socket_perms;

	# If yes, transition to its own domain.
	domtrans_pattern(xend_t, qemu_dm_exec_t, qemu_dm_t)

	append_files_pattern(qemu_dm_t, xend_var_log_t, xend_var_log_t)

	rw_fifo_files_pattern(qemu_dm_t, xend_var_run_t, xend_var_run_t)

	corenet_tcp_bind_generic_node(qemu_dm_t)
	corenet_tcp_bind_vnc_port(qemu_dm_t)

	dev_rw_xen(qemu_dm_t)

	files_read_etc_files(qemu_dm_t)
	files_read_usr_files(qemu_dm_t)

	fs_manage_xenfs_dirs(qemu_dm_t)
	fs_manage_xenfs_files(qemu_dm_t)

	miscfiles_read_localization(qemu_dm_t)

	xen_stream_connect_xenstore(qemu_dm_t)
',`
        # If no, then silently refuse to run it.
	dontaudit xend_t qemu_dm_exec_t:file { execute execute_no_trans };
')

########################################
#
# xend local policy
#

allow xend_t self:capability { dac_override ipc_lock net_admin setuid sys_nice sys_tty_config net_raw };
dontaudit xend_t self:capability { sys_ptrace };
allow xend_t self:process { signal sigkill };
dontaudit xend_t self:process ptrace;
# internal communication is often done using fifo and unix sockets.
allow xend_t self:fifo_file rw_fifo_file_perms;
allow xend_t self:unix_stream_socket create_stream_socket_perms;
allow xend_t self:unix_dgram_socket create_socket_perms;
allow xend_t self:netlink_route_socket r_netlink_socket_perms;
allow xend_t self:tcp_socket create_stream_socket_perms;
allow xend_t self:packet_socket create_socket_perms;

allow xend_t xen_image_t:dir list_dir_perms;
manage_dirs_pattern(xend_t, xen_image_t, xen_image_t)
manage_files_pattern(xend_t, xen_image_t, xen_image_t)
read_lnk_files_pattern(xend_t, xen_image_t, xen_image_t)
rw_blk_files_pattern(xend_t, xen_image_t, xen_image_t)

allow xend_t xenctl_t:fifo_file manage_fifo_file_perms;
dev_filetrans(xend_t, xenctl_t, fifo_file)

manage_files_pattern(xend_t, xend_tmp_t, xend_tmp_t)
manage_dirs_pattern(xend_t, xend_tmp_t, xend_tmp_t)
files_tmp_filetrans(xend_t, xend_tmp_t, { file dir })

# pid file
manage_dirs_pattern(xend_t, xend_var_run_t, xend_var_run_t)
manage_files_pattern(xend_t, xend_var_run_t, xend_var_run_t)
manage_sock_files_pattern(xend_t, xend_var_run_t, xend_var_run_t)
manage_fifo_files_pattern(xend_t, xend_var_run_t, xend_var_run_t)
files_pid_filetrans(xend_t, xend_var_run_t, { file sock_file fifo_file dir })

# log files
manage_dirs_pattern(xend_t, xend_var_log_t, xend_var_log_t)
manage_files_pattern(xend_t, xend_var_log_t, xend_var_log_t)
manage_sock_files_pattern(xend_t, xend_var_log_t, xend_var_log_t)
logging_log_filetrans(xend_t, xend_var_log_t, { sock_file file dir })

# var/lib files for xend
manage_dirs_pattern(xend_t, xend_var_lib_t, xend_var_lib_t)
manage_files_pattern(xend_t, xend_var_lib_t, xend_var_lib_t)
manage_sock_files_pattern(xend_t, xend_var_lib_t, xend_var_lib_t)
manage_fifo_files_pattern(xend_t, xend_var_lib_t, xend_var_lib_t)
files_var_lib_filetrans(xend_t, xend_var_lib_t, { file dir })

# transition to store
domtrans_pattern(xend_t, xenstored_exec_t, xenstored_t)

# manage xenstored pid file
manage_files_pattern(xend_t, xenstored_var_run_t, xenstored_var_run_t)

# mount tmpfs on /var/lib/xenstored
allow xend_t xenstored_var_lib_t:dir read;

# transition to console
domtrans_pattern(xend_t, xenconsoled_exec_t, xenconsoled_t)

kernel_read_kernel_sysctls(xend_t)
kernel_read_system_state(xend_t)
kernel_write_xen_state(xend_t)
kernel_read_xen_state(xend_t)
kernel_rw_net_sysctls(xend_t)
kernel_read_network_state(xend_t)

corecmd_exec_bin(xend_t)
corecmd_exec_shell(xend_t)

corenet_all_recvfrom_unlabeled(xend_t)
corenet_all_recvfrom_netlabel(xend_t)
corenet_tcp_sendrecv_generic_if(xend_t)
corenet_tcp_sendrecv_generic_node(xend_t)
corenet_tcp_sendrecv_all_ports(xend_t)
corenet_tcp_bind_generic_node(xend_t)
corenet_tcp_bind_xen_port(xend_t)
corenet_tcp_bind_soundd_port(xend_t)
corenet_tcp_bind_generic_port(xend_t)
corenet_tcp_bind_vnc_port(xend_t)
corenet_tcp_connect_xserver_port(xend_t)
corenet_tcp_connect_xen_port(xend_t)
corenet_sendrecv_xserver_client_packets(xend_t)
corenet_sendrecv_xen_server_packets(xend_t)
corenet_sendrecv_xen_client_packets(xend_t)
corenet_sendrecv_soundd_server_packets(xend_t)
corenet_rw_tun_tap_dev(xend_t)

dev_read_urand(xend_t)
dev_filetrans_xen(xend_t)
dev_rw_sysfs(xend_t)
dev_rw_xen(xend_t)

domain_dontaudit_read_all_domains_state(xend_t)
domain_dontaudit_ptrace_all_domains(xend_t)

files_read_etc_files(xend_t)
files_read_kernel_symbol_table(xend_t)
files_read_kernel_img(xend_t)
files_manage_etc_runtime_files(xend_t)
files_etc_filetrans_etc_runtime(xend_t, file)
files_read_usr_files(xend_t)
files_read_default_symlinks(xend_t)

term_getattr_all_ptys(xend_t)
term_use_generic_ptys(xend_t)
term_use_ptmx(xend_t)
term_getattr_pty_fs(xend_t)

init_stream_connect_script(xend_t)

locallogin_dontaudit_use_fds(xend_t)

logging_send_syslog_msg(xend_t)

lvm_domtrans(xend_t)

miscfiles_read_localization(xend_t)
miscfiles_read_hwdata(xend_t)

mount_domtrans(xend_t)

sysnet_domtrans_dhcpc(xend_t)
sysnet_signal_dhcpc(xend_t)
sysnet_domtrans_ifconfig(xend_t)
sysnet_dns_name_resolve(xend_t)
sysnet_delete_dhcpc_pid(xend_t)
sysnet_read_dhcpc_pid(xend_t)
sysnet_rw_dhcp_config(xend_t)

userdom_dontaudit_search_user_home_dirs(xend_t)

xen_stream_connect_xenstore(xend_t)

netutils_domtrans(xend_t)

optional_policy(`
	brctl_domtrans(xend_t)
')

optional_policy(`
	consoletype_exec(xend_t)
')

########################################
#
# Xen console local policy
#

allow xenconsoled_t self:capability { dac_override fsetid ipc_lock };
allow xenconsoled_t self:process setrlimit;
allow xenconsoled_t self:unix_stream_socket create_stream_socket_perms;
allow xenconsoled_t self:fifo_file rw_fifo_file_perms;

allow xenconsoled_t xen_devpts_t:chr_file rw_term_perms;

# pid file
manage_files_pattern(xenconsoled_t, xenconsoled_var_run_t, xenconsoled_var_run_t)
manage_sock_files_pattern(xenconsoled_t, xenconsoled_var_run_t, xenconsoled_var_run_t)
files_pid_filetrans(xenconsoled_t, xenconsoled_var_run_t, { file sock_file })

kernel_read_kernel_sysctls(xenconsoled_t)
kernel_write_xen_state(xenconsoled_t)
kernel_read_xen_state(xenconsoled_t)

dev_rw_xen(xenconsoled_t)
dev_filetrans_xen(xenconsoled_t)
dev_rw_sysfs(xenconsoled_t)

domain_dontaudit_ptrace_all_domains(xenconsoled_t)

files_read_etc_files(xenconsoled_t)
files_read_usr_files(xenconsoled_t)

fs_list_tmpfs(xenconsoled_t)
fs_manage_xenfs_dirs(xenconsoled_t)
fs_manage_xenfs_files(xenconsoled_t)

term_create_pty(xenconsoled_t, xen_devpts_t)
term_use_generic_ptys(xenconsoled_t)
term_use_console(xenconsoled_t)

init_use_fds(xenconsoled_t)
init_use_script_ptys(xenconsoled_t)

miscfiles_read_localization(xenconsoled_t)

xen_manage_log(xenconsoled_t)
xen_stream_connect_xenstore(xenconsoled_t)

optional_policy(`
	ptchown_domtrans(xenconsoled_t)
')

########################################
#
# Xen store local policy
#

allow xenstored_t self:capability { dac_override ipc_lock sys_resource };
allow xenstored_t self:unix_stream_socket create_stream_socket_perms;
allow xenstored_t self:unix_dgram_socket create_socket_perms;

manage_files_pattern(xenstored_t, xenstored_tmp_t, xenstored_tmp_t)
manage_dirs_pattern(xenstored_t, xenstored_tmp_t, xenstored_tmp_t)
files_tmp_filetrans(xenstored_t, xenstored_tmp_t, { file dir })

# pid file
manage_files_pattern(xenstored_t, xenstored_var_run_t, xenstored_var_run_t)
manage_sock_files_pattern(xenstored_t, xenstored_var_run_t, xenstored_var_run_t)
files_pid_filetrans(xenstored_t, xenstored_var_run_t, { file sock_file })

# log files
manage_dirs_pattern(xenstored_t, xenstored_var_log_t, xenstored_var_log_t)
manage_files_pattern(xenstored_t, xenstored_var_log_t, xenstored_var_log_t)
manage_sock_files_pattern(xenstored_t, xenstored_var_log_t, xenstored_var_log_t)
logging_log_filetrans(xenstored_t, xenstored_var_log_t, { sock_file file dir })

# var/lib files for xenstored
manage_dirs_pattern(xenstored_t, xenstored_var_lib_t, xenstored_var_lib_t)
manage_files_pattern(xenstored_t, xenstored_var_lib_t, xenstored_var_lib_t)
manage_sock_files_pattern(xenstored_t, xenstored_var_lib_t, xenstored_var_lib_t)
files_var_lib_filetrans(xenstored_t, xenstored_var_lib_t, { file dir sock_file })

stream_connect_pattern(xenstored_t, evtchnd_var_run_t, evtchnd_var_run_t, evtchnd_t)

kernel_write_xen_state(xenstored_t)
kernel_read_xen_state(xenstored_t)

dev_filetrans_xen(xenstored_t)
dev_rw_xen(xenstored_t)
dev_read_sysfs(xenstored_t)

files_read_etc_files(xenstored_t)

files_read_usr_files(xenstored_t)

fs_manage_xenfs_files(xenstored_t)

term_use_generic_ptys(xenstored_t)

init_use_fds(xenstored_t)
init_use_script_ptys(xenstored_t)

logging_send_syslog_msg(xenstored_t)

miscfiles_read_localization(xenstored_t)

xen_append_log(xenstored_t)

########################################
#
# xm local policy
#

allow xm_t self:capability { dac_override ipc_lock sys_tty_config };
allow xm_t self:process { getsched signal };

# internal communication is often done using fifo and unix sockets.
allow xm_t self:fifo_file rw_fifo_file_perms;
allow xm_t self:unix_stream_socket { create_stream_socket_perms connectto };
allow xm_t self:tcp_socket create_stream_socket_perms;

manage_files_pattern(xm_t, xend_var_lib_t, xend_var_lib_t)
manage_fifo_files_pattern(xm_t, xend_var_lib_t, xend_var_lib_t)
manage_sock_files_pattern(xm_t, xend_var_lib_t, xend_var_lib_t)
files_search_var_lib(xm_t)

allow xm_t xen_image_t:dir rw_dir_perms;
allow xm_t xen_image_t:file read_file_perms;
allow xm_t xen_image_t:blk_file read_blk_file_perms;

kernel_read_system_state(xm_t)
kernel_read_kernel_sysctls(xm_t)
kernel_read_sysctl(xm_t)
kernel_read_xen_state(xm_t)
kernel_write_xen_state(xm_t)

corecmd_exec_bin(xm_t)
corecmd_exec_shell(xm_t)

corenet_tcp_sendrecv_generic_if(xm_t)
corenet_tcp_sendrecv_generic_node(xm_t)
corenet_tcp_connect_soundd_port(xm_t)

dev_read_urand(xm_t)
dev_read_sysfs(xm_t)

files_read_etc_runtime_files(xm_t)
files_read_usr_files(xm_t)
files_list_mnt(xm_t)
# Some common macros (you might be able to remove some)
files_read_etc_files(xm_t)

fs_getattr_all_fs(xm_t)
fs_manage_xenfs_dirs(xm_t)
fs_manage_xenfs_files(xm_t)

term_use_all_terms(xm_t)

init_stream_connect_script(xm_t)
init_rw_script_stream_sockets(xm_t)
init_use_fds(xm_t)

miscfiles_read_localization(xm_t)

sysnet_dns_name_resolve(xm_t)

xen_append_log(xm_t)
xen_stream_connect(xm_t)
xen_stream_connect_xenstore(xm_t)

optional_policy(`
	dbus_system_bus_client(xm_t)

	optional_policy(`
		hal_dbus_chat(xm_t)
	')
')

optional_policy(`
	virt_domtrans(xm_t)
	virt_manage_images(xm_t)
	virt_manage_config(xm_t)
	virt_stream_connect(xm_t)
')

########################################
#
# SSH component local policy
#
optional_policy(`
	ssh_basic_client_template(xm, xm_t, system_r)

	kernel_read_xen_state(xm_ssh_t)
	kernel_write_xen_state(xm_ssh_t)

	files_search_tmp(xm_ssh_t)

	fs_manage_xenfs_dirs(xm_ssh_t)
	fs_manage_xenfs_files(xm_ssh_t)

	#Should have a boolean wrapping these
	fs_list_auto_mountpoints(xend_t)
	files_search_mnt(xend_t)
	fs_getattr_all_fs(xend_t)
	fs_read_dos_files(xend_t)
	fs_manage_xenfs_dirs(xend_t)
	fs_manage_xenfs_files(xend_t)

	tunable_policy(`xen_use_nfs',`
		fs_manage_nfs_files(xend_t)
		fs_read_nfs_symlinks(xend_t)
	')

	optional_policy(`
		unconfined_domain(xend_t)
	')
')