policy_module(virt, 1.4.0) ######################################## # # Declarations # ## ##

## Allow virt to use serial/parallell communication ports ##

##
gen_tunable(virt_use_comm, false) ## ##

## Allow virt to read fuse files ##

##
gen_tunable(virt_use_fusefs, false) ## ##

## Allow virt to manage nfs files ##

##
gen_tunable(virt_use_nfs, false) ## ##

## Allow virt to manage cifs files ##

##
gen_tunable(virt_use_samba, false) ## ##

## Allow virt to manage device configuration, (pci) ##

##
gen_tunable(virt_use_sysfs, false) ## ##

## Allow virt to use usb devices ##

##
gen_tunable(virt_use_usb, true) virt_domain_template(svirt) role system_r types svirt_t; type svirt_cache_t; files_type(svirt_cache_t) attribute virt_domain; attribute virt_image_type; type virt_etc_t; files_config_file(virt_etc_t) type virt_etc_rw_t; files_type(virt_etc_rw_t) # virt Image files type virt_image_t; # customizable virt_image(virt_image_t) # virt Image files type virt_content_t; # customizable virt_image(virt_content_t) userdom_user_home_content(virt_content_t) type virt_log_t; logging_log_file(virt_log_t) type virt_var_run_t; files_pid_file(virt_var_run_t) type virt_var_lib_t; files_type(virt_var_lib_t) type virtd_t; type virtd_exec_t; init_daemon_domain(virtd_t, virtd_exec_t) domain_obj_id_change_exemption(virtd_t) domain_subj_id_change_exemption(virtd_t) type virtd_initrc_exec_t; init_script_file(virtd_initrc_exec_t) ifdef(`enable_mcs',` init_ranged_daemon_domain(virtd_t, virtd_exec_t, s0 - mcs_systemhigh) ') ifdef(`enable_mls',` init_ranged_daemon_domain(virtd_t, virtd_exec_t, s0 - mls_systemhigh) ') ######################################## # # svirt local policy # allow svirt_t self:udp_socket create_socket_perms; manage_dirs_pattern(svirt_t, svirt_cache_t, svirt_cache_t) manage_files_pattern(svirt_t, svirt_cache_t, svirt_cache_t) files_var_filetrans(svirt_t, svirt_cache_t, { file dir }) read_lnk_files_pattern(svirt_t, virt_image_t, virt_image_t) allow svirt_t svirt_image_t:dir search_dir_perms; manage_dirs_pattern(svirt_t, svirt_image_t, svirt_image_t) manage_files_pattern(svirt_t, svirt_image_t, svirt_image_t) fs_hugetlbfs_filetrans(svirt_t, svirt_image_t, file) list_dirs_pattern(svirt_t, virt_content_t, virt_content_t) read_files_pattern(svirt_t, virt_content_t, virt_content_t) dontaudit svirt_t virt_content_t:file write_file_perms; dontaudit svirt_t virt_content_t:dir write; corenet_udp_sendrecv_generic_if(svirt_t) corenet_udp_sendrecv_generic_node(svirt_t) corenet_udp_sendrecv_all_ports(svirt_t) corenet_udp_bind_generic_node(svirt_t) corenet_udp_bind_all_ports(svirt_t) corenet_tcp_bind_all_ports(svirt_t) corenet_tcp_connect_all_ports(svirt_t) dev_list_sysfs(svirt_t) userdom_search_user_home_content(svirt_t) userdom_read_user_home_content_symlinks(svirt_t) userdom_read_all_users_state(svirt_t) tunable_policy(`virt_use_comm',` term_use_unallocated_ttys(svirt_t) dev_rw_printer(svirt_t) ') tunable_policy(`virt_use_fusefs',` fs_read_fusefs_files(svirt_t) fs_read_fusefs_symlinks(svirt_t) ') tunable_policy(`virt_use_nfs',` fs_manage_nfs_dirs(svirt_t) fs_manage_nfs_files(svirt_t) ') tunable_policy(`virt_use_samba',` fs_manage_cifs_dirs(svirt_t) fs_manage_cifs_files(svirt_t) ') tunable_policy(`virt_use_sysfs',` dev_rw_sysfs(svirt_t) ') tunable_policy(`virt_use_usb',` dev_rw_usbfs(svirt_t) fs_manage_dos_dirs(svirt_t) fs_manage_dos_files(svirt_t) ') optional_policy(` xen_rw_image_files(svirt_t) ') ######################################## # # virtd local policy # allow virtd_t self:capability { chown dac_override fowner ipc_lock kill mknod net_admin net_raw setpcap setuid setgid sys_admin sys_nice sys_ptrace }; allow virtd_t self:process { getcap getsched setcap sigkill signal signull execmem setexec setfscreate setsched }; allow virtd_t self:fifo_file rw_fifo_file_perms; allow virtd_t self:unix_stream_socket create_stream_socket_perms; allow virtd_t self:tcp_socket create_stream_socket_perms; allow virtd_t self:tun_socket create_socket_perms; allow virtd_t self:netlink_kobject_uevent_socket create_socket_perms; manage_dirs_pattern(virtd_t, svirt_cache_t, svirt_cache_t) manage_files_pattern(virtd_t, svirt_cache_t, svirt_cache_t) manage_dirs_pattern(virtd_t, virt_content_t, virt_content_t) manage_files_pattern(virtd_t, virt_content_t, virt_content_t) allow virtd_t virt_domain:process { getattr getsched setsched transition signal signull sigkill }; read_files_pattern(virtd_t, virt_etc_t, virt_etc_t) read_lnk_files_pattern(virtd_t, virt_etc_t, virt_etc_t) manage_dirs_pattern(virtd_t, virt_etc_rw_t, virt_etc_rw_t) manage_files_pattern(virtd_t, virt_etc_rw_t, virt_etc_rw_t) manage_lnk_files_pattern(virtd_t, virt_etc_rw_t, virt_etc_rw_t) filetrans_pattern(virtd_t, virt_etc_t, virt_etc_rw_t, dir) manage_files_pattern(virtd_t, virt_image_type, virt_image_type) manage_blk_files_pattern(virtd_t, virt_image_type, virt_image_type) allow virtd_t virt_image_type:file { relabelfrom relabelto }; allow virtd_t virt_image_type:blk_file { relabelfrom relabelto }; manage_dirs_pattern(virtd_t, virt_log_t, virt_log_t) manage_files_pattern(virtd_t, virt_log_t, virt_log_t) logging_log_filetrans(virtd_t, virt_log_t, { file dir }) manage_dirs_pattern(virtd_t, virt_var_lib_t, virt_var_lib_t) manage_files_pattern(virtd_t, virt_var_lib_t, virt_var_lib_t) manage_sock_files_pattern(virtd_t, virt_var_lib_t, virt_var_lib_t) files_var_lib_filetrans(virtd_t, virt_var_lib_t, { file dir }) manage_dirs_pattern(virtd_t, virt_var_run_t, virt_var_run_t) manage_files_pattern(virtd_t, virt_var_run_t, virt_var_run_t) manage_sock_files_pattern(virtd_t, virt_var_run_t, virt_var_run_t) files_pid_filetrans(virtd_t, virt_var_run_t, { file dir }) kernel_read_system_state(virtd_t) kernel_read_network_state(virtd_t) kernel_rw_net_sysctls(virtd_t) kernel_request_load_module(virtd_t) kernel_search_debugfs(virtd_t) corecmd_exec_bin(virtd_t) corecmd_exec_shell(virtd_t) corenet_all_recvfrom_unlabeled(virtd_t) corenet_all_recvfrom_netlabel(virtd_t) corenet_tcp_sendrecv_generic_if(virtd_t) corenet_tcp_sendrecv_generic_node(virtd_t) corenet_tcp_sendrecv_all_ports(virtd_t) corenet_tcp_bind_generic_node(virtd_t) corenet_tcp_bind_virt_port(virtd_t) corenet_tcp_bind_vnc_port(virtd_t) corenet_tcp_connect_vnc_port(virtd_t) corenet_tcp_connect_soundd_port(virtd_t) corenet_rw_tun_tap_dev(virtd_t) dev_rw_sysfs(virtd_t) dev_read_rand(virtd_t) dev_rw_kvm(virtd_t) dev_getattr_all_chr_files(virtd_t) dev_rw_mtrr(virtd_t) # Init script handling domain_use_interactive_fds(virtd_t) domain_read_all_domains_state(virtd_t) files_read_usr_files(virtd_t) files_read_etc_files(virtd_t) files_read_etc_runtime_files(virtd_t) files_search_all(virtd_t) files_read_kernel_modules(virtd_t) files_read_usr_src_files(virtd_t) files_manage_etc_files(virtd_t) fs_list_auto_mountpoints(virtd_t) fs_getattr_xattr_fs(virtd_t) fs_rw_anon_inodefs_files(virtd_t) fs_list_inotifyfs(virtd_t) fs_manage_cgroup_dirs(virtd_t) fs_rw_cgroup_files(virtd_t) mcs_process_set_categories(virtd_t) storage_manage_fixed_disk(virtd_t) storage_relabel_fixed_disk(virtd_t) storage_raw_write_removable_device(virtd_t) storage_raw_read_removable_device(virtd_t) term_getattr_pty_fs(virtd_t) term_use_generic_ptys(virtd_t) term_use_ptmx(virtd_t) auth_use_nsswitch(virtd_t) miscfiles_read_localization(virtd_t) miscfiles_read_certs(virtd_t) miscfiles_read_hwdata(virtd_t) modutils_read_module_deps(virtd_t) modutils_read_module_config(virtd_t) modutils_manage_module_config(virtd_t) logging_send_syslog_msg(virtd_t) seutil_read_default_contexts(virtd_t) sysnet_domtrans_ifconfig(virtd_t) sysnet_read_config(virtd_t) userdom_getattr_all_users(virtd_t) userdom_list_user_home_content(virtd_t) userdom_read_all_users_state(virtd_t) userdom_read_user_home_content_files(virtd_t) tunable_policy(`virt_use_nfs',` fs_manage_nfs_dirs(virtd_t) fs_manage_nfs_files(virtd_t) fs_read_nfs_symlinks(virtd_t) ') tunable_policy(`virt_use_samba',` fs_manage_nfs_files(virtd_t) fs_manage_cifs_files(virtd_t) fs_read_cifs_symlinks(virtd_t) ') optional_policy(` brctl_domtrans(virtd_t) ') optional_policy(` dbus_system_bus_client(virtd_t) optional_policy(` avahi_dbus_chat(virtd_t) ') optional_policy(` consolekit_dbus_chat(virtd_t) ') optional_policy(` hal_dbus_chat(virtd_t) ') ') optional_policy(` dnsmasq_domtrans(virtd_t) dnsmasq_signal(virtd_t) dnsmasq_kill(virtd_t) dnsmasq_read_pid_files(virtd_t) dnsmasq_signull(virtd_t) ') optional_policy(` iptables_domtrans(virtd_t) iptables_initrc_domtrans(virtd_t) # Manages /etc/sysconfig/system-config-firewall iptables_manage_config(virtd_t) ') optional_policy(` kerberos_keytab_template(virtd, virtd_t) ') optional_policy(` lvm_domtrans(virtd_t) ') optional_policy(` policykit_dbus_chat(virtd_t) policykit_domtrans_auth(virtd_t) policykit_domtrans_resolve(virtd_t) policykit_read_lib(virtd_t) ') optional_policy(` qemu_domtrans(virtd_t) qemu_read_state(virtd_t) qemu_signal(virtd_t) qemu_kill(virtd_t) qemu_setsched(virtd_t) ') optional_policy(` sasl_connect(virtd_t) ') optional_policy(` kernel_read_xen_state(virtd_t) kernel_write_xen_state(virtd_t) xen_stream_connect(virtd_t) xen_stream_connect_xenstore(virtd_t) xen_read_image_files(virtd_t) ') optional_policy(` udev_domtrans(virtd_t) udev_read_db(virtd_t) ') optional_policy(` unconfined_domain(virtd_t) ') ######################################## # # virtual domains common policy # allow virt_domain self:capability { dac_read_search dac_override kill }; allow virt_domain self:process { execmem execstack signal getsched signull }; allow virt_domain self:fifo_file rw_file_perms; allow virt_domain self:shm create_shm_perms; allow virt_domain self:unix_stream_socket create_stream_socket_perms; allow virt_domain self:unix_dgram_socket { create_socket_perms sendto }; allow virt_domain self:tcp_socket create_stream_socket_perms; append_files_pattern(virt_domain, virt_log_t, virt_log_t) append_files_pattern(virt_domain, virt_var_lib_t, virt_var_lib_t) kernel_read_system_state(virt_domain) corecmd_exec_bin(virt_domain) corecmd_exec_shell(virt_domain) corenet_all_recvfrom_unlabeled(virt_domain) corenet_all_recvfrom_netlabel(virt_domain) corenet_tcp_sendrecv_generic_if(virt_domain) corenet_tcp_sendrecv_generic_node(virt_domain) corenet_tcp_sendrecv_all_ports(virt_domain) corenet_tcp_bind_generic_node(virt_domain) corenet_tcp_bind_vnc_port(virt_domain) corenet_rw_tun_tap_dev(virt_domain) corenet_tcp_bind_virt_migration_port(virt_domain) corenet_tcp_connect_virt_migration_port(virt_domain) dev_read_rand(virt_domain) dev_read_sound(virt_domain) dev_read_urand(virt_domain) dev_write_sound(virt_domain) dev_rw_ksm(virt_domain) dev_rw_kvm(virt_domain) dev_rw_qemu(virt_domain) domain_use_interactive_fds(virt_domain) files_read_etc_files(virt_domain) files_read_usr_files(virt_domain) files_read_var_files(virt_domain) files_search_all(virt_domain) fs_getattr_tmpfs(virt_domain) fs_rw_anon_inodefs_files(virt_domain) fs_rw_tmpfs_files(virt_domain) term_use_all_terms(virt_domain) term_getattr_pty_fs(virt_domain) term_use_generic_ptys(virt_domain) term_use_ptmx(virt_domain) auth_use_nsswitch(virt_domain) logging_send_syslog_msg(virt_domain) miscfiles_read_localization(virt_domain) optional_policy(` ptchown_domtrans(virt_domain) ') optional_policy(` virt_read_config(virt_domain) virt_read_lib_files(virt_domain) virt_read_content(virt_domain) virt_stream_connect(virt_domain) ')