selinux-policy/policy/modules/services/virt.te
Paul Moore 9dc3cd1635 refpol: Policy for the new TUN driver access controls
Add policy for the new TUN driver access controls which allow policy to
control which domains have the ability to create and attach to TUN/TAP
devices.  The policy rules for creating and attaching to a device are as
shown below:

  # create a new device
  allow domain_t self:tun_socket { create };

  # attach to a persistent device (created by tunlbl_t)
  allow domain_t tunlbl_t:tun_socket { relabelfrom };
  allow domain_t self:tun_socket { relabelto };

Further discussion can be found on this thread:

 * http://marc.info/?t=125080850900002&r=1&w=2

Signed-off-by: Paul Moore <paul.moore@hp.com>
2009-08-31 08:36:06 -04:00

204 lines
4.5 KiB
Plaintext

policy_module(virt, 1.2.0)
########################################
#
# Declarations
#
## <desc>
## <p>
## Allow virt to manage nfs files
## </p>
## </desc>
gen_tunable(virt_use_nfs, false)
## <desc>
## <p>
## Allow virt to manage cifs files
## </p>
## </desc>
gen_tunable(virt_use_samba, false)
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, virt_image_type; # customizable
virt_image(virt_image_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)
type virtd_initrc_exec_t;
init_script_file(virtd_initrc_exec_t)
########################################
#
# virtd local policy
#
allow virtd_t self:capability { dac_override kill net_admin setgid sys_nice sys_ptrace };
allow virtd_t self:process { getsched sigkill signal execmem };
allow virtd_t self:fifo_file rw_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;
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_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)
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_load_module(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_read_sysfs(virtd_t)
dev_read_rand(virtd_t)
# Init script handling
domain_use_interactive_fds(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_list_kernel_modules(virtd_t)
fs_list_auto_mountpoints(virtd_t)
storage_raw_write_removable_device(virtd_t)
storage_raw_read_removable_device(virtd_t)
term_getattr_pty_fs(virtd_t)
term_use_ptmx(virtd_t)
auth_use_nsswitch(virtd_t)
miscfiles_read_localization(virtd_t)
miscfiles_read_certs(virtd_t)
logging_send_syslog_msg(virtd_t)
userdom_read_all_users_state(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)
')
optional_policy(`
iptables_domtrans(virtd_t)
')
#optional_policy(`
# polkit_domtrans_auth(virtd_t)
# polkit_domtrans_resolve(virtd_t)
#')
optional_policy(`
qemu_domtrans(virtd_t)
qemu_read_state(virtd_t)
qemu_signal(virtd_t)
qemu_kill(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)
')
optional_policy(`
unconfined_domain(virtd_t)
')