Skip to content

Commit d4fee5f

Browse files
committed
fixup! Introduce SELinux policy for libvirt drivers
1 parent 67362aa commit d4fee5f

File tree

2 files changed

+51
-9
lines changed

2 files changed

+51
-9
lines changed

virt.if

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,15 @@ template(`virt_driver_template',`
137137
allow $1_t virt_var_run_t:dir { create search_dir_perms };
138138
manage_dirs_pattern($1_t, $1_var_run_t, $1_var_run_t)
139139
manage_files_pattern($1_t, $1_var_run_t, $1_var_run_t)
140-
files_pid_filetrans($1_t, $1_var_run_t, { dir file } )
141-
filetrans_pattern($1_t, virt_var_run_t, $1_var_run_t, { dir file } )
140+
manage_sock_files_pattern($1_t, virt_var_run_t, $1_var_run_t)
141+
files_pid_filetrans($1_t, $1_var_run_t, { dir file sock_file } )
142+
filetrans_pattern($1_t, virt_var_run_t, $1_var_run_t, { dir file sock_file } )
142143

143144
read_files_pattern($1_t, virt_etc_t, virt_etc_t)
144145
manage_dirs_pattern($1_t, virt_etc_rw_t, virt_etc_rw_t)
145146
manage_files_pattern($1_t, virt_etc_rw_t, virt_etc_rw_t)
146147

148+
allow virt_driver_domain virtqemud_t:unix_stream_socket connectto;
147149
read_files_pattern(virt_driver_domain, virtqemud_t, virtqemud_t)
148150

149151
kernel_dgram_send($1_t)

virt.te

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ virt_driver_template(virtsecretd)
302302
# virtstoraged
303303
virt_driver_template(virtstoraged)
304304

305+
type virtstoraged_tmp_t;
306+
files_tmp_file(virtstoraged_tmp_t)
307+
305308
# virtvboxd
306309
virt_driver_template(virtvboxd)
307310

@@ -814,6 +817,8 @@ allow virtlogd_t virtd_t:dir list_dir_perms;
814817
allow virtlogd_t virtd_t:file read_file_perms;
815818
allow virtlogd_t virtd_t:lnk_file read_lnk_file_perms;
816819

820+
read_files_pattern(virtlogd_t, virtqemud_t, virtqemud_t)
821+
817822
virt_manage_lib_files(virtlogd_t)
818823

819824
tunable_policy(`virt_lockd_blk_devs',`
@@ -1657,26 +1662,32 @@ tunable_policy(`virt_sandbox_use_audit',`
16571662

16581663
userdom_use_user_ptys(svirt_qemu_net_t)
16591664

1660-
16611665
#######################################
16621666
#
16631667
# virtinterfaced local policy
16641668
#
16651669
allow virtinterfaced_t self:tcp_socket create_stream_socket_perms;
16661670

1671+
corecmd_exec_bin(virtinterfaced_t)
1672+
1673+
fs_getattr_all_fs(virtinterfaced_t)
1674+
16671675
modutils_read_module_config(virtinterfaced_t)
16681676

16691677
sysnet_read_config(virtinterfaced_t)
1678+
1679+
userdom_read_all_users_state(virtinterfaced_t)
1680+
16701681
#######################################
16711682
#
16721683
# virtnetworkd local policy
16731684
#
16741685
allow virtnetworkd_t self:capability { kill sys_ptrace };
16751686
allow virtnetworkd_t self:netlink_netfilter_socket create_socket_perms;
16761687
allow virtnetworkd_t self:process setcap;
1677-
allow virtnetworkd_t self:tun_socket create;
1688+
allow virtnetworkd_t self:tun_socket { create relabelfrom relabelto };
16781689

1679-
read_lnk_files_pattern(virtnetworkd_t, virt_etc_rw_t, virt_etc_rw_t)
1690+
manage_lnk_files_pattern(virtnetworkd_t, virt_etc_rw_t, virt_etc_rw_t)
16801691

16811692
manage_dirs_pattern(virtnetworkd_t, virt_var_lib_t, virt_var_lib_t)
16821693
manage_files_pattern(virtnetworkd_t, virt_var_lib_t, virt_var_lib_t)
@@ -1694,6 +1705,9 @@ sysnet_read_config(virtnetworkd_t)
16941705
optional_policy(`
16951706
dnsmasq_domtrans(virtnetworkd_t)
16961707
dnsmasq_manage_pid_files(virtnetworkd_t)
1708+
dnsmasq_read_state(virtnetworkd_t)
1709+
dnsmasq_signal(virtnetworkd_t)
1710+
dnsmasq_signull(virtnetworkd_t)
16971711
')
16981712

16991713
optional_policy(`
@@ -1709,6 +1723,8 @@ optional_policy(`
17091723
allow virtnodedevd_t self:capability sys_admin;
17101724
allow virtnodedevd_t self:netlink_generic_socket create_socket_perms;
17111725

1726+
kernel_request_load_module(virtnodedevd_t)
1727+
17121728
dev_rw_mtrr(virtnodedevd_t)
17131729

17141730
miscfiles_read_hwdata(virtnodedevd_t)
@@ -1723,8 +1739,12 @@ optional_policy(`
17231739
#
17241740
allow virtnwfilterd_t self:capability net_raw;
17251741
allow virtnwfilterd_t self:netlink_netfilter_socket create_socket_perms;
1742+
allow virtnwfilterd_t self:packet_socket { bind create getopt ioctl map setopt };
17261743
allow virtnwfilterd_t self:rawip_socket create_socket_perms;
17271744

1745+
kernel_read_net_sysctls(virtnwfilterd_t)
1746+
kernel_request_load_module(virtnwfilterd_t)
1747+
17281748
manage_dirs_pattern(virtnwfilterd_t, virtnetworkd_var_run_t, virtnetworkd_var_run_t)
17291749
manage_files_pattern(virtnwfilterd_t, virtnetworkd_var_run_t, virtnetworkd_var_run_t)
17301750

@@ -1744,12 +1764,14 @@ optional_policy(`
17441764
#
17451765
allow virtproxyd_t self:udp_socket create_socket_perms;
17461766

1767+
userdom_read_all_users_state(virtproxyd_t)
1768+
17471769
#######################################
17481770
#
17491771
# virtqemud local policy
17501772
#
17511773
allow virtqemud_t self:bpf { map_create map_read map_write prog_load prog_run };
1752-
allow virtqemud_t self:capability { audit_write chown dac_override dac_read_search fowner fsetid kill setgid setuid sys_admin sys_chroot sys_ptrace };
1774+
allow virtqemud_t self:capability { audit_write chown dac_override dac_read_search fowner fsetid kill setgid setuid sys_admin sys_chroot sys_ptrace sys_rawio };
17531775
allow virtqemud_t self:netlink_audit_socket nlmsg_relay;
17541776
allow virtqemud_t self:process { setcap setexec setrlimit setsockcreate };
17551777
allow virtqemud_t self:tcp_socket { bind create setopt };
@@ -1762,9 +1784,12 @@ allow virtqemud_t virt_driver_domain:unix_stream_socket connectto;
17621784

17631785
manage_files_pattern(virtqemud_t, virt_image_t, virt_image_t)
17641786

1787+
read_files_pattern(virtqemud_t, virtproxyd_t, virtproxyd_t)
1788+
17651789
allow virtqemud_t svirt_t:process { setsched signal signull transition };
1766-
allow virtqemud_t svirt_t:unix_stream_socket create_socket_perms;
1790+
allow virtqemud_t svirt_t:unix_stream_socket { connectto create_stream_socket_perms };
17671791
read_files_pattern(virtqemud_t, svirt_t, svirt_t)
1792+
read_lnk_files_pattern(virtqemud_t, svirt_t, svirt_t)
17681793

17691794
manage_dirs_pattern(virtqemud_t, svirt_image_t, svirt_image_t)
17701795
manage_files_pattern(virtqemud_t, svirt_image_t, svirt_image_t)
@@ -1789,6 +1814,7 @@ corenet_rw_tun_tap_dev(virtqemud_t)
17891814
corenet_tcp_bind_generic_node(virtqemud_t)
17901815
corenet_tcp_bind_vnc_port(virtqemud_t)
17911816

1817+
dev_read_cpuid(virtqemud_t)
17921818
dev_read_sysfs(virtqemud_t)
17931819
dev_read_urand(virtqemud_t)
17941820
dev_relabel_all_dev_nodes(virtqemud_t)
@@ -1803,13 +1829,19 @@ fs_manage_hugetlbfs_dirs(virtqemud_t)
18031829
fs_manage_cgroup_dirs(virtqemud_t)
18041830
fs_manage_cgroup_files(virtqemud_t)
18051831
fs_manage_tmpfs_chr_files(virtqemud_t)
1832+
fs_manage_tmpfs_dirs(virtqemud_t)
1833+
fs_manage_tmpfs_symlinks(virtqemud_t)
1834+
fs_mount_tmpfs(virtqemud_t)
18061835
fs_read_nsfs_files(virtqemud_t)
1836+
fs_relabel_tmpfs_chr_file(virtqemud_t)
18071837

1838+
init_stream_connect(virtqemud_t)
18081839
init_stream_connect_script(virtqemud_t)
18091840

18101841
seutil_read_default_contexts(virtqemud_t)
18111842
seutil_read_file_contexts(virtqemud_t)
18121843

1844+
userdom_read_all_users_state(virtqemud_t)
18131845
userdom_read_user_home_content_files(virtqemud_t)
18141846
userdom_relabel_user_home_files(virtqemud_t)
18151847

@@ -1825,14 +1857,22 @@ optional_policy(`
18251857
#
18261858
# virtstoraged local policy
18271859
#
1828-
manage_files_pattern(virtstoraged_t, virt_image_t, virt_image_t)
1860+
allow virtstoraged_t self:capability { dac_override dac_read_search };
1861+
1862+
files_tmp_filetrans(virtstoraged_t, virtstoraged_tmp_t, { file dir })
18291863

18301864
manage_lnk_files_pattern(virtstoraged_t, virt_etc_rw_t, virt_etc_rw_t)
18311865

1866+
manage_files_pattern(virtstoraged_t, virt_image_t, virt_image_t)
1867+
1868+
manage_files_pattern(virtstoraged_t, svirt_image_t, svirt_image_t)
1869+
18321870
manage_dirs_pattern(virtstoraged_t, virt_var_lib_t, virt_var_lib_t)
18331871
manage_files_pattern(virtstoraged_t, virt_var_lib_t, virt_var_lib_t)
18341872

1835-
fs_getattr_xattr_fs(virtstoraged_t)
1873+
corecmd_exec_bin(virtstoraged_t)
1874+
1875+
fs_getattr_all_fs(virtstoraged_t)
18361876

18371877
userdom_read_user_home_content_files(virtstoraged_t)
18381878

0 commit comments

Comments
 (0)