Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
97 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
policy_module(swtpm_libvirt, 1.0.0) | ||
|
||
######################################## | ||
# | ||
# Rules for enabling interactions due to swtpm usage by libvirt | ||
# Requires Fedora 40 | ||
# | ||
|
||
require { | ||
type admin_home_t; | ||
type device_t; | ||
type fs_t; | ||
type hugetlbfs_t; | ||
type qemu_var_run_t; | ||
type svirt_t; | ||
type svirt_image_t; | ||
type svirt_tcg_t; | ||
type svirt_tcg_devpts_t; | ||
type swtpm_t; | ||
type urandom_device_t; | ||
type var_lib_t; | ||
type var_log_t; | ||
type virt_var_lib_t; | ||
type virtqemud_t; | ||
} | ||
|
||
allow virtqemud_t admin_home_t:file { relabelfrom relabelto setattr write }; | ||
allow virtqemud_t device_t:filesystem unmount; | ||
allow virtqemud_t fs_t:filesystem getattr; | ||
allow virtqemud_t hugetlbfs_t:dir relabelfrom; | ||
allow virtqemud_t qemu_var_run_t:file { relabelfrom relabelto }; | ||
allow virtqemud_t qemu_var_run_t:sock_file relabelfrom; | ||
allow virtqemud_t self:capability { sys_nice sys_module }; | ||
allow virtqemud_t self:fifo_file relabelfrom; | ||
allow virtqemud_t svirt_t:process { noatsecure rlimitinh siginh }; | ||
allow virtqemud_t svirt_image_t:chr_file setattr; | ||
allow virtqemud_t svirt_tcg_t:dir search; | ||
allow virtqemud_t svirt_tcg_t:file { open read }; | ||
allow virtqemud_t svirt_tcg_t:process { noatsecure rlimitinh setsched siginh signal signull transition }; | ||
allow virtqemud_t svirt_tcg_t:unix_stream_socket { bind connectto create listen }; | ||
allow virtqemud_t svirt_tcg_devpts_t:chr_file { ioctl open read write }; | ||
allow virtqemud_t swtpm_t:process { noatsecure rlimitinh siginh signull }; | ||
allow virtqemud_t urandom_device_t:chr_file setattr; | ||
|
||
# Some rules are due to swtpm-localca ( https://bugzilla.redhat.com/show_bug.cgi?id=2278905#c34 ) | ||
allow virtqemud_t var_lib_t:dir add_name; | ||
allow virtqemud_t var_lib_t:file { create setattr write }; | ||
|
||
allow virtqemud_t var_log_t:dir { add_name remove_name }; | ||
allow virtqemud_t var_log_t:file { create relabelfrom relabelto setattr unlink write }; | ||
allow virtqemud_t virt_var_lib_t:dir { relabelfrom relabelto }; | ||
allow virtqemud_t virt_var_lib_t:file { relabelfrom relabelto }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
policy_module(swtpm_svirt,1.0) | ||
|
||
######################################## | ||
# | ||
# Requires Fedora 40 | ||
# | ||
|
||
require { | ||
type svirt_image_t; | ||
type svirt_t; | ||
type svirt_tcg_t; | ||
type swtpm_exec_t; | ||
type virtd_t; | ||
type user_tmp_t; | ||
type virt_var_run_t; | ||
type virtd_t; | ||
type virtqemud_t; | ||
} | ||
|
||
swtpm_domtrans(svirt_t) | ||
swtpm_domtrans(svirt_tcg_t) | ||
|
||
#============= svirt_t ============== | ||
allow svirt_t virtd_t:fifo_file { read write }; | ||
allow svirt_t virtd_t:process sigchld; | ||
allow svirt_t swtpm_exec_t:file entrypoint; | ||
|
||
# Due to session mode and usage of dir /run/user/*/libvirt/qemu/run/swtpm | ||
allow svirt_t user_tmp_t:sock_file { create setattr unlink }; | ||
allow svirt_t swtpm_exec_t:file { entrypoint map }; | ||
# libvirt specific rules needed on F28 | ||
allow svirt_t virtd_t:unix_stream_socket { read write getopt getattr accept }; | ||
# virt_var_run_t rules needed on F30 | ||
allow svirt_t virt_var_run_t:dir { add_name remove_name write }; | ||
allow svirt_t virt_var_run_t:file { create getattr open read unlink write }; | ||
allow svirt_t virt_var_run_t:sock_file { create setattr }; | ||
|
||
allow svirt_tcg_t virtd_t:fifo_file { write read }; | ||
allow svirt_tcg_t virt_var_run_t:sock_file { create setattr unlink }; | ||
allow svirt_tcg_t virt_var_run_t:file { create getattr open read unlink write }; | ||
allow svirt_tcg_t virt_var_run_t:dir { write add_name remove_name }; | ||
allow svirt_tcg_t swtpm_exec_t:file { entrypoint map }; | ||
allow svirt_tcg_t user_tmp_t:sock_file { create setattr unlink }; | ||
# libvirt specific rules needed on F28 | ||
allow svirt_tcg_t virtd_t:unix_stream_socket { read write getopt getattr accept }; | ||
allow svirt_t virtd_t:dir search; | ||
allow svirt_t virtd_t:fifo_file write; | ||
allow svirt_t virtqemud_t:fifo_file write; | ||
|
||
allow svirt_tcg_t swtpm_exec_t:file entrypoint; | ||
allow svirt_tcg_t svirt_image_t:file { map read write }; # also: domain_can_mmap_files | ||
allow svirt_tcg_t virtqemud_t:fifo_file write; | ||
allow svirt_tcg_t virtqemud_t:file { getattr open read }; |