Billy McFall | 28cf3b7 | 2018-01-15 17:54:52 -0500 | [diff] [blame] | 1 | policy_module(vpp-custom,1.0) |
| 2 | |
| 3 | ######################################## |
| 4 | # |
| 5 | # Declarations |
| 6 | # |
| 7 | |
| 8 | gen_require(` |
| 9 | type hugetlbfs_t; |
| 10 | type svirt_t; |
| 11 | type svirt_image_t; |
| 12 | type systemd_sysctl_t; |
| 13 | class capability sys_admin; |
| 14 | ') |
| 15 | |
| 16 | type vpp_t; |
| 17 | type vpp_exec_t; |
| 18 | init_daemon_domain(vpp_t, vpp_exec_t) |
| 19 | |
| 20 | type vpp_config_rw_t; |
| 21 | files_config_file(vpp_config_rw_t) |
| 22 | |
| 23 | type vpp_lib_t; # if there is vpp_var_lib_t, we don't need vpp_lib_t |
| 24 | files_type(vpp_lib_t) |
| 25 | |
| 26 | type vpp_log_t; |
| 27 | logging_log_file(vpp_log_t) |
| 28 | |
| 29 | type vpp_var_run_t; |
| 30 | files_type(vpp_var_run_t) |
| 31 | |
| 32 | type vpp_unit_file_t; |
| 33 | systemd_unit_file(vpp_unit_file_t) |
| 34 | |
| 35 | type vpp_tmpfs_t; |
| 36 | files_tmpfs_file(vpp_tmpfs_t) |
| 37 | |
| 38 | type vpp_tmp_t; |
| 39 | files_tmp_file(vpp_tmp_t) |
| 40 | |
| 41 | ######################################## |
| 42 | # |
| 43 | # vpp local policy |
| 44 | # |
| 45 | |
Billy McFall | 5b82610 | 2019-05-16 15:58:58 -0400 | [diff] [blame] | 46 | allow vpp_t self:capability { dac_override ipc_lock setgid sys_rawio net_raw sys_admin net_admin chown }; # too benevolent |
Billy McFall | 28cf3b7 | 2018-01-15 17:54:52 -0500 | [diff] [blame] | 47 | dontaudit vpp_t self:capability2 block_suspend; |
Victor Nguyen -T (victong2 - OTHERWISE PORTAGE at Cisco) | 3f8562e | 2018-02-27 18:20:03 +0100 | [diff] [blame] | 48 | allow vpp_t self:process { execmem execstack setsched signal }; # too benevolent |
Martin Millnert | 6884935 | 2020-09-11 01:02:26 +0200 | [diff] [blame] | 49 | allow vpp_t self:packet_socket { bind create setopt ioctl map read write }; |
Billy McFall | 28cf3b7 | 2018-01-15 17:54:52 -0500 | [diff] [blame] | 50 | allow vpp_t self:tun_socket { create relabelto relabelfrom }; |
| 51 | allow vpp_t self:udp_socket { create ioctl }; |
| 52 | allow vpp_t self:unix_dgram_socket { connect create ioctl }; |
| 53 | allow vpp_t self:unix_stream_socket { create_stream_socket_perms connectto }; |
Billy McFall | 5b82610 | 2019-05-16 15:58:58 -0400 | [diff] [blame] | 54 | allow vpp_t self:netlink_route_socket { bind create nlmsg_write read write getattr setopt }; |
| 55 | allow vpp_t self:netlink_socket { bind create setopt }; |
Billy McFall | 28cf3b7 | 2018-01-15 17:54:52 -0500 | [diff] [blame] | 56 | |
| 57 | manage_dirs_pattern(vpp_t, vpp_lib_t, vpp_lib_t) |
| 58 | manage_files_pattern(vpp_t, vpp_lib_t, vpp_lib_t) |
| 59 | allow vpp_t vpp_lib_t:file execute; |
| 60 | files_var_lib_filetrans(vpp_t, vpp_lib_t, {file dir}) |
| 61 | |
| 62 | manage_dirs_pattern(vpp_t, vpp_log_t, vpp_log_t) |
| 63 | manage_files_pattern(vpp_t, vpp_log_t, vpp_log_t) |
| 64 | logging_log_filetrans(vpp_t, vpp_log_t, {file dir}) |
| 65 | |
| 66 | manage_dirs_pattern(vpp_t, vpp_var_run_t, vpp_var_run_t) |
| 67 | manage_files_pattern(vpp_t, vpp_var_run_t, vpp_var_run_t) |
| 68 | manage_sock_files_pattern(vpp_t, vpp_var_run_t, vpp_var_run_t) |
| 69 | allow vpp_t vpp_var_run_t:dir mounton; |
| 70 | files_pid_filetrans(vpp_t, vpp_var_run_t, { dir sock_file file }) |
| 71 | |
| 72 | manage_dirs_pattern(vpp_t, vpp_tmp_t, vpp_tmp_t) |
| 73 | manage_files_pattern(vpp_t, vpp_tmp_t, vpp_tmp_t) |
| 74 | manage_sock_files_pattern(vpp_t, vpp_tmp_t, vpp_tmp_t) |
| 75 | allow vpp_t vpp_tmp_t:dir mounton; |
| 76 | files_tmp_filetrans(vpp_t, vpp_tmp_t, { dir sock_file file }) |
| 77 | |
| 78 | manage_dirs_pattern(vpp_t, vpp_tmpfs_t, vpp_tmpfs_t) |
| 79 | manage_files_pattern(vpp_t, vpp_tmpfs_t, vpp_tmpfs_t) |
| 80 | fs_tmpfs_filetrans(vpp_t, vpp_tmpfs_t, { dir file }) |
| 81 | |
| 82 | read_files_pattern(vpp_t, vpp_config_rw_t, vpp_config_rw_t) |
| 83 | |
| 84 | kernel_read_system_state(vpp_t) |
| 85 | kernel_read_network_state(vpp_t) |
| 86 | kernel_dgram_send(vpp_t) |
| 87 | kernel_request_load_module(vpp_t) |
| 88 | |
| 89 | auth_read_passwd(vpp_t) |
| 90 | |
| 91 | corenet_rw_tun_tap_dev(vpp_t) |
| 92 | |
Billy McFall | 5b82610 | 2019-05-16 15:58:58 -0400 | [diff] [blame] | 93 | dev_rw_infiniband_dev(vpp_t) |
Billy McFall | 28cf3b7 | 2018-01-15 17:54:52 -0500 | [diff] [blame] | 94 | dev_rw_userio_dev(vpp_t) |
| 95 | dev_rw_sysfs(vpp_t) |
| 96 | dev_read_cpuid(vpp_t) |
| 97 | dev_rw_vfio_dev(vpp_t) |
Billy McFall | 1ac36d7 | 2018-03-14 09:34:02 -0400 | [diff] [blame] | 98 | dev_rw_vhost( vpp_t ) |
Billy McFall | 41decea | 2019-05-16 09:13:50 -0400 | [diff] [blame] | 99 | dev_rw_generic_chr_files(vpp_t) |
Billy McFall | 28cf3b7 | 2018-01-15 17:54:52 -0500 | [diff] [blame] | 100 | |
| 101 | domain_obj_id_change_exemption(vpp_t) |
| 102 | |
| 103 | fs_manage_hugetlbfs_dirs(vpp_t) |
| 104 | fs_manage_hugetlbfs_files(vpp_t) |
| 105 | allow vpp_t hugetlbfs_t:filesystem { getattr mount unmount }; |
| 106 | fs_getattr_tmpfs(vpp_t) |
| 107 | |
| 108 | logging_send_syslog_msg(vpp_t) |
| 109 | |
| 110 | miscfiles_read_generic_certs(vpp_t) |
| 111 | |
| 112 | userdom_list_user_home_content(vpp_t) |
| 113 | |
| 114 | optional_policy(` |
| 115 | virt_stream_connect_svirt(vpp_t) |
| 116 | ') |
| 117 | |
| 118 | optional_policy(` |
| 119 | unconfined_attach_tun_iface(vpp_t) |
| 120 | ') |
| 121 | |
| 122 | |
| 123 | ######################################## |
| 124 | # |
| 125 | # svirt local policy for vpp |
| 126 | # |
| 127 | |
| 128 | allow svirt_t vpp_t:unix_stream_socket connectto; |
| 129 | |
| 130 | manage_dirs_pattern(svirt_t, vpp_var_run_t, vpp_var_run_t) |
| 131 | manage_files_pattern(svirt_t, vpp_var_run_t, vpp_var_run_t) |
| 132 | manage_sock_files_pattern(svirt_t, vpp_var_run_t, vpp_var_run_t) |
| 133 | |
| 134 | allow vpp_t svirt_image_t:file { read write }; |
| 135 | |
| 136 | |
| 137 | ######################################## |
| 138 | # |
| 139 | # systemd_sysctl_t local policy for vpp |
| 140 | # |
| 141 | |
| 142 | read_files_pattern(systemd_sysctl_t, vpp_config_rw_t, vpp_config_rw_t) |
| 143 | |
| 144 | |