1 |
commit: f04ea627a99d4b6650f22da3ac0a4e4a97b34b63 |
2 |
Author: Jonathan Davies <jpds <AT> protonmail <DOT> com> |
3 |
AuthorDate: Wed Jul 14 21:30:37 2021 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 5 14:26:44 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=f04ea627 |
7 |
|
8 |
virt: Defined a virt_common_runtime_t type for the new common/system.token file and added permissions to virtd_t and virtlogd_t. |
9 |
|
10 |
Modelled on: https://github.com/fedora-selinux/selinux-policy/commit/1f761d0bbdc08d21a91cdcbd1909ddb53858e354 |
11 |
libvirt change introducing this: https://gitlab.com/libvirt/libvirt/-/commit/cbfebfc74741a00bddf67b7fa10892b757fffd6a |
12 |
|
13 |
Signed-off-by: Jonathan Davies <jpds <AT> protonmail.com> |
14 |
Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org> |
15 |
|
16 |
policy/modules/services/virt.fc | 1 + |
17 |
policy/modules/services/virt.te | 11 +++++++++++ |
18 |
2 files changed, 12 insertions(+) |
19 |
|
20 |
diff --git a/policy/modules/services/virt.fc b/policy/modules/services/virt.fc |
21 |
index 5266b68c..ab5d0885 100644 |
22 |
--- a/policy/modules/services/virt.fc |
23 |
+++ b/policy/modules/services/virt.fc |
24 |
@@ -58,6 +58,7 @@ HOME_DIR/VirtualMachines/isos(/.*)? gen_context(system_u:object_r:virt_content_t |
25 |
/run/libguestfs(/.*)? gen_context(system_u:object_r:virt_runtime_t,s0) |
26 |
/run/libvirtd\.pid -- gen_context(system_u:object_r:virt_runtime_t,s0) |
27 |
/run/libvirt(/.*)? gen_context(system_u:object_r:virt_runtime_t,s0) |
28 |
+/run/libvirt/common(/.*)? gen_context(system_u:object_r:virt_common_runtime_t,s0) |
29 |
/run/libvirt/lxc(/.*)? gen_context(system_u:object_r:virtd_lxc_runtime_t,s0) |
30 |
/run/libvirt-sandbox(/.*)? gen_context(system_u:object_r:virtd_lxc_runtime_t,s0) |
31 |
/run/libvirt/qemu(/.*)? gen_context(system_u:object_r:svirt_runtime_t,s0-mls_systemhigh) |
32 |
|
33 |
diff --git a/policy/modules/services/virt.te b/policy/modules/services/virt.te |
34 |
index da88b2cb..47c6042c 100644 |
35 |
--- a/policy/modules/services/virt.te |
36 |
+++ b/policy/modules/services/virt.te |
37 |
@@ -129,6 +129,9 @@ type virt_image_t; # customizable |
38 |
virt_image(virt_image_t) |
39 |
files_mountpoint(virt_image_t) |
40 |
|
41 |
+type virt_common_runtime_t; |
42 |
+files_runtime_file(virt_common_runtime_t) |
43 |
+ |
44 |
type virt_content_t; # customizable |
45 |
virt_image(virt_content_t) |
46 |
userdom_user_home_content(virt_content_t) |
47 |
@@ -581,6 +584,11 @@ manage_files_pattern(virtd_t, virt_runtime_t, virt_runtime_t) |
48 |
manage_sock_files_pattern(virtd_t, virt_runtime_t, virt_runtime_t) |
49 |
files_runtime_filetrans(virtd_t, virt_runtime_t, { file dir }) |
50 |
|
51 |
+allow virtd_t virt_common_runtime_t:file append_file_perms; |
52 |
+manage_dirs_pattern(virtd_t, virt_common_runtime_t, virt_common_runtime_t) |
53 |
+manage_files_pattern(virtd_t, virt_common_runtime_t, virt_common_runtime_t) |
54 |
+filetrans_pattern(virtd_t, virt_runtime_t, virt_common_runtime_t, dir, "common") |
55 |
+ |
56 |
manage_dirs_pattern(virtd_t, virtd_lxc_runtime_t, virtd_lxc_runtime_t) |
57 |
manage_files_pattern(virtd_t, virtd_lxc_runtime_t, virtd_lxc_runtime_t) |
58 |
filetrans_pattern(virtd_t, virt_runtime_t, virtd_lxc_runtime_t, dir, "lxc") |
59 |
@@ -1371,6 +1379,9 @@ manage_sock_files_pattern(virtlogd_t, virt_runtime_t, virtlogd_run_t) |
60 |
filetrans_pattern(virtlogd_t, virt_runtime_t, virtlogd_run_t, sock_file) |
61 |
files_runtime_filetrans(virtlogd_t, virtlogd_run_t, file) |
62 |
|
63 |
+allow virtlogd_t virt_common_runtime_t:file append_file_perms; |
64 |
+manage_files_pattern(virtlogd_t, virt_runtime_t, virt_common_runtime_t) |
65 |
+ |
66 |
kernel_read_system_state(virtlogd_t) |
67 |
|
68 |
files_read_etc_files(virtlogd_t) |