From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 73740158083 for ; Sun, 22 Sep 2024 00:03:39 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 46F02E29AA; Sun, 22 Sep 2024 00:03:38 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2EF65E29A9 for ; Sun, 22 Sep 2024 00:03:38 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 5F76E34317D for ; Sun, 22 Sep 2024 00:03:37 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8885627FC for ; Sun, 22 Sep 2024 00:03:35 +0000 (UTC) From: "Jason Zaman" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Jason Zaman" Message-ID: <1726957709.7f5c42c7e77b42d5b92e77fff62ffb2a243e1007.perfinion@gentoo> Subject: [gentoo-commits] proj/hardened-refpolicy:master commit in: policy/modules/services/ X-VCS-Repository: proj/hardened-refpolicy X-VCS-Files: policy/modules/services/container.te X-VCS-Directories: policy/modules/services/ X-VCS-Committer: perfinion X-VCS-Committer-Name: Jason Zaman X-VCS-Revision: 7f5c42c7e77b42d5b92e77fff62ffb2a243e1007 X-VCS-Branch: master Date: Sun, 22 Sep 2024 00:03:35 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 9fb9fcd1-4cc8-4d73-82c3-49c04824f1d8 X-Archives-Hash: 591e1bad5cd070d40e611b375d4d3fd8 commit: 7f5c42c7e77b42d5b92e77fff62ffb2a243e1007 Author: Kenton Groombridge gentoo org> AuthorDate: Fri Aug 9 19:30:01 2024 +0000 Commit: Jason Zaman gentoo org> CommitDate: Sat Sep 21 22:28:29 2024 +0000 URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=7f5c42c7 container: add container_kvm_t and supporting kubevirt rules container_kvm_t is the type for containers with access to KVM for running virtual machines. Signed-off-by: Kenton Groombridge gentoo.org> Signed-off-by: Jason Zaman gentoo.org> policy/modules/services/container.te | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/policy/modules/services/container.te b/policy/modules/services/container.te index 2353092e4..e91cd18f4 100644 --- a/policy/modules/services/container.te +++ b/policy/modules/services/container.te @@ -180,6 +180,12 @@ ifdef(`enable_mls',` ') mls_trusted_object(container_engine_t) +container_domain_template(container_kvm) +typeattribute container_kvm_t container_system_domain, container_net_domain; +optional_policy(` + kubernetes_container(container_kvm_t) +') + type spc_t, container_domain, container_net_domain, container_system_domain, privileged_container_domain; domain_type(spc_t) role system_r types spc_t; @@ -942,6 +948,28 @@ filetrans_pattern(container_engine_user_domain, container_data_home_t, container filetrans_pattern(container_engine_user_domain, container_data_home_t, container_ro_file_t, dir, "overlay2-layers") filetrans_pattern(container_engine_user_domain, container_data_home_t, container_file_t, dir, "volumes") +######################################## +# +# KVM container local policy +# + +allow container_kvm_t self:process { getcap setrlimit }; +allow container_kvm_t self:capability { net_admin sys_resource }; +allow container_kvm_t self:tun_socket { relabelfrom relabelto }; + +dev_getattr_mtrr_dev(container_kvm_t) +dev_read_sysfs(container_kvm_t) + +fs_read_cgroup_files(container_kvm_t) + +kernel_read_device_sysctls(container_kvm_t) +kernel_read_irq_sysctls(container_kvm_t) +kernel_read_vm_overcommit_sysctl(container_kvm_t) + +allow container_kvm_t spc_t:fd use; +allow container_kvm_t spc_t:fifo_file write; +allow container_kvm_t spc_t:tun_socket relabelfrom; + ######################################## # # Common privileged container local policy @@ -974,7 +1002,7 @@ domtrans_pattern(container_engine_system_domain, container_file_t, spc_t) domtrans_pattern(container_engine_system_domain, container_ro_file_t, spc_t) domtrans_pattern(container_engine_system_domain, container_var_lib_t, spc_t) -allow spc_t self:process { getcap setrlimit }; +allow spc_t self:process { getcap setexec setrlimit }; # Normally triggered when rook-ceph executes lvm tools which creates noise. # This can be allowed if actually needed. dontaudit spc_t self:process setfscreate; @@ -1127,6 +1155,10 @@ allow spc_t container_config_t:dir watch; allow spc_t container_runtime_t:lnk_file manage_lnk_file_perms; allow spc_t container_runtime_t:file watch; +# for kubevirt +allow spc_t container_kvm_t:process transition; +ps_process_pattern(spc_t, container_kvm_t) + ifdef(`init_systemd',` init_dbus_chat(spc_t) init_run_bpf(spc_t)