commit:     f04ea627a99d4b6650f22da3ac0a4e4a97b34b63
Author:     Jonathan Davies <jpds <AT> protonmail <DOT> com>
AuthorDate: Wed Jul 14 21:30:37 2021 +0000
Commit:     Jason Zaman <perfinion <AT> gentoo <DOT> org>
CommitDate: Sun Sep  5 14:26:44 2021 +0000
URL:        
https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=f04ea627

virt: Defined a virt_common_runtime_t type for the new common/system.token file 
and added permissions to virtd_t and virtlogd_t.

Modelled on: 
https://github.com/fedora-selinux/selinux-policy/commit/1f761d0bbdc08d21a91cdcbd1909ddb53858e354
libvirt change introducing this: 
https://gitlab.com/libvirt/libvirt/-/commit/cbfebfc74741a00bddf67b7fa10892b757fffd6a

Signed-off-by: Jonathan Davies <jpds <AT> protonmail.com>
Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org>

 policy/modules/services/virt.fc |  1 +
 policy/modules/services/virt.te | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/policy/modules/services/virt.fc b/policy/modules/services/virt.fc
index 5266b68c..ab5d0885 100644
--- a/policy/modules/services/virt.fc
+++ b/policy/modules/services/virt.fc
@@ -58,6 +58,7 @@ HOME_DIR/VirtualMachines/isos(/.*)?   
gen_context(system_u:object_r:virt_content_t
 /run/libguestfs(/.*)?  gen_context(system_u:object_r:virt_runtime_t,s0)
 /run/libvirtd\.pid     --      gen_context(system_u:object_r:virt_runtime_t,s0)
 /run/libvirt(/.*)?     gen_context(system_u:object_r:virt_runtime_t,s0)
+/run/libvirt/common(/.*)?      
gen_context(system_u:object_r:virt_common_runtime_t,s0)
 /run/libvirt/lxc(/.*)? gen_context(system_u:object_r:virtd_lxc_runtime_t,s0)
 /run/libvirt-sandbox(/.*)?     
gen_context(system_u:object_r:virtd_lxc_runtime_t,s0)
 /run/libvirt/qemu(/.*)?        
gen_context(system_u:object_r:svirt_runtime_t,s0-mls_systemhigh)

diff --git a/policy/modules/services/virt.te b/policy/modules/services/virt.te
index da88b2cb..47c6042c 100644
--- a/policy/modules/services/virt.te
+++ b/policy/modules/services/virt.te
@@ -129,6 +129,9 @@ type virt_image_t; # customizable
 virt_image(virt_image_t)
 files_mountpoint(virt_image_t)
 
+type virt_common_runtime_t;
+files_runtime_file(virt_common_runtime_t)
+
 type virt_content_t; # customizable
 virt_image(virt_content_t)
 userdom_user_home_content(virt_content_t)
@@ -581,6 +584,11 @@ manage_files_pattern(virtd_t, virt_runtime_t, 
virt_runtime_t)
 manage_sock_files_pattern(virtd_t, virt_runtime_t, virt_runtime_t)
 files_runtime_filetrans(virtd_t, virt_runtime_t, { file dir })
 
+allow virtd_t virt_common_runtime_t:file append_file_perms;
+manage_dirs_pattern(virtd_t, virt_common_runtime_t, virt_common_runtime_t)
+manage_files_pattern(virtd_t, virt_common_runtime_t, virt_common_runtime_t)
+filetrans_pattern(virtd_t, virt_runtime_t, virt_common_runtime_t, dir, 
"common")
+
 manage_dirs_pattern(virtd_t, virtd_lxc_runtime_t, virtd_lxc_runtime_t)
 manage_files_pattern(virtd_t, virtd_lxc_runtime_t, virtd_lxc_runtime_t)
 filetrans_pattern(virtd_t, virt_runtime_t, virtd_lxc_runtime_t, dir, "lxc")
@@ -1371,6 +1379,9 @@ manage_sock_files_pattern(virtlogd_t, virt_runtime_t, 
virtlogd_run_t)
 filetrans_pattern(virtlogd_t, virt_runtime_t, virtlogd_run_t, sock_file)
 files_runtime_filetrans(virtlogd_t, virtlogd_run_t, file)
 
+allow virtlogd_t virt_common_runtime_t:file append_file_perms;
+manage_files_pattern(virtlogd_t, virt_runtime_t, virt_common_runtime_t)
+
 kernel_read_system_state(virtlogd_t)
 
 files_read_etc_files(virtlogd_t)

Reply via email to