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