missed patches: VFIO support to libvirt
Hi Chris,
It appears these patches slipped through earlier on so im resending on behalf of Alexander Wetzel.
They were originally sent here:
http://oss.tresys.com/pipermail/refpolicy/2015-June/007661.html
The related Gentoo Bug:
https://bugs.gentoo.org/522736
PATCH 1/1 add vfio support for libvirt
From: Alexander Wetzel <[email protected]>
Signed-off-by Alexander Wetzel <[email protected]>
--- virt.te | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
virt.te +19 -0
@@ -70,6 +70,14 @@ gen_tunable(virt_use_usb, false) ## </desc> gen_tunable(virt_use_xserver, false) +## <desc> +### <p> +### Determine whether confined virtual guests +### can use vfio for pci device pass through (vt-d). +### </p> +### </desc> +gen_tunable(virt_use_vfio, false) + attribute virt_ptynode; attribute virt_domain; attribute virt_image_type;
@@ -415,6 +423,10 @@ corenet_tcp_bind_all_ports(svirt_t) corenet_sendrecv_all_client_packets(svirt_t) corenet_tcp_connect_all_ports(svirt_t) +tunable_policy(`virt_use_vfio',` + dev_rw_vfio_dev(svirt_t) +') + ######################################## # # virtd local policy
@@ -658,6 +670,13 @@ tunable_policy(`virt_use_samba',` fs_read_cifs_symlinks(virtd_t) ') +tunable_policy(`virt_use_vfio',` + allow virtd_t self:capability sys_resource; + allow virtd_t self:process setrlimit; + allow virtd_t svirt_t:process rlimitinh; + dev_relabelfrom_vfio_dev(virtd_t) +') + optional_policy(` brctl_domtrans(virtd_t) ')
Signature · 1 line
2.4.0
PATCH 1/1 add vfio support for libvirt
Quoted 1 line · Jason Zaman
From: Alexander Wetzel <[email protected]>
Merged.
Quoted 50 lines
Signed-off-by Alexander Wetzel <[email protected]>--- virt.te | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)virt.te +19
-0@@ -70,6 +70,14 @@ gen_tunable(virt_use_usb, false) ## </desc> gen_tunable(virt_use_xserver, false) +## <desc> +### <p> +### Determine whether confined virtual guests +### can use vfio for pci device pass through (vt-d). +### </p> +### </desc> +gen_tunable(virt_use_vfio, false) + attribute virt_ptynode; attribute virt_domain; attribute virt_image_type;@@ -415,6 +423,10 @@ corenet_tcp_bind_all_ports(svirt_t) corenet_sendrecv_all_client_packets(svirt_t) corenet_tcp_connect_all_ports(svirt_t) +tunable_policy(`virt_use_vfio',` + dev_rw_vfio_dev(svirt_t) +') + ######################################## # # virtd local policy@@ -658,6 +670,13 @@ tunable_policy(`virt_use_samba',` fs_read_cifs_symlinks(virtd_t) ') +tunable_policy(`virt_use_vfio',` + allow virtd_t self:capability sys_resource; + allow virtd_t self:process setrlimit; + allow virtd_t svirt_t:process rlimitinh; + dev_relabelfrom_vfio_dev(virtd_t) +') + optional_policy(` brctl_domtrans(virtd_t) ')
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com
PATCH 1/1 adds vfio device support to base policy
In reply to Jason ZamanFrom: Alexander Wetzel <[email protected]>
Signed-off-by Alexander Wetzel <[email protected]>
--- policy/modules/kernel/devices.fc | 1 + policy/modules/kernel/devices.if | 36 ++++++++++++++++++++++++++++++++++++ policy/modules/kernel/devices.te | 3 +++ 3 files changed, 40 insertions(+)
policy/modules/kernel/devices.fc +1 -0
@@ -118,6 +118,7 @@ ifdef(`distro_suse', ` /dev/usbscanner -c gen_context(system_u:object_r:scanner_device_t,s0) ') +/dev/vfio/.+ -c gen_context(system_u:object_r:vfio_device_t,s0) /dev/vhost-net -c gen_context(system_u:object_r:vhost_device_t,s0) /dev/vbi.* -c gen_context(system_u:object_r:v4l_device_t,s0) /dev/vbox.* -c gen_context(system_u:object_r:xserver_misc_device_t,s0)
policy/modules/kernel/devices.if +36 -0
@@ -4611,6 +4611,42 @@ interface(`dev_write_video_dev',` ######################################## ## <summary> +## Read and write vfio devices. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_rw_vfio_dev',` + gen_require(` + type device_t, vfio_device_t; + ') + + rw_chr_files_pattern($1, device_t, vfio_device_t) +') + +######################################## +## <summary> +## Relabel vfio devices. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_relabelfrom_vfio_dev',` + gen_require(` + type device_t, vfio_device_t; + ') + + relabelfrom_chr_files_pattern($1, device_t, vfio_device_t) +') + +############################ +## <summary> ## Allow read/write the vhost net device ## </summary> ## <param name="domain">
policy/modules/kernel/devices.te +3 -0
@@ -273,6 +273,9 @@ dev_node(usbmon_device_t) type userio_device_t; dev_node(userio_device_t) +type vfio_device_t; +dev_node(vfio_device_t) + type v4l_device_t; dev_node(v4l_device_t)
Signature · 1 line
2.4.0
PATCH 1/1 adds vfio device support to base policy
Quoted 1 line · Jason Zaman
From: Alexander Wetzel <[email protected]>
Merged.
Quoted 81 lines
Signed-off-by Alexander Wetzel <[email protected]>--- policy/modules/kernel/devices.fc | 1 + policy/modules/kernel/devices.if | 36 ++++++++++++++++++++++++++++++++++++ policy/modules/kernel/devices.te | 3 +++ 3 files changed, 40 insertions(+)policy/modules/kernel/devices.fc +1
-0@@ -118,6 +118,7 @@ ifdef(`distro_suse', ` /dev/usbscanner -c gen_context(system_u:object_r:scanner_device_t,s0) ') +/dev/vfio/.+ -c gen_context(system_u:object_r:vfio_device_t,s0) /dev/vhost-net -c gen_context(system_u:object_r:vhost_device_t,s0) /dev/vbi.* -c gen_context(system_u:object_r:v4l_device_t,s0) /dev/vbox.* -c gen_context(system_u:object_r:xserver_misc_device_t,s0)policy/modules/kernel/devices.if +36
-0@@ -4611,6 +4611,42 @@ interface(`dev_write_video_dev',` ######################################## ## <summary> +## Read and write vfio devices. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_rw_vfio_dev',` + gen_require(` + type device_t, vfio_device_t; + ') + + rw_chr_files_pattern($1, device_t, vfio_device_t) +') + +######################################## +## <summary> +## Relabel vfio devices. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`dev_relabelfrom_vfio_dev',` + gen_require(` + type device_t, vfio_device_t; + ') + + relabelfrom_chr_files_pattern($1, device_t, vfio_device_t) +') + +############################ +## <summary> ## Allow read/write the vhost net device ## </summary> ## <param name="domain">policy/modules/kernel/devices.te +3
-0@@ -273,6 +273,9 @@ dev_node(usbmon_device_t) type userio_device_t; dev_node(userio_device_t) +type vfio_device_t; +dev_node(vfio_device_t) + type v4l_device_t; dev_node(v4l_device_t)
Signature · 3 lines
Chris PeBenito Tresys Technology, LLC www.tresys.com | oss.tresys.com