aboutsummaryrefslogtreecommitdiff
blob: bacb3794d96d48c3a0d8762d73ba318c2832811a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
policy_module(sysnetwork, 1.24.1)

########################################
#
# Declarations
#

attribute_role dhcpc_roles;
roleattribute system_r dhcpc_roles;

# this is shared between dhcpc and dhcpd:
type dhcp_etc_t;
files_config_file(dhcp_etc_t)

# this is shared between dhcpc and dhcpd:
type dhcp_state_t;
files_type(dhcp_state_t)

type dhcpc_t;
type dhcpc_exec_t;
init_daemon_domain(dhcpc_t, dhcpc_exec_t)
role dhcpc_roles types dhcpc_t;

type dhcpc_runtime_t alias dhcpc_var_run_t;
files_pid_file(dhcpc_runtime_t)

type dhcpc_state_t;
files_type(dhcpc_state_t)

type dhcpc_tmp_t;
files_tmp_file(dhcpc_tmp_t)

type ifconfig_t;
type ifconfig_exec_t;
init_system_domain(ifconfig_t, ifconfig_exec_t)
role system_r types ifconfig_t;

type net_conf_t;
files_type(net_conf_t)

ifdef(`distro_debian',`
	init_daemon_pid_file(net_conf_t, dir, "network")
')

########################################
#
# DHCP client local policy
#
allow dhcpc_t self:capability { dac_override fsetid net_admin net_bind_service net_raw setpcap sys_nice sys_resource sys_tty_config };
dontaudit dhcpc_t self:capability { sys_admin sys_ptrace sys_tty_config };
# for access("/etc/bashrc", X_OK) on Red Hat
dontaudit dhcpc_t self:capability { dac_read_search sys_module };
allow dhcpc_t self:process { getsched getcap setcap setfscreate ptrace signal_perms };

allow dhcpc_t self:fifo_file rw_fifo_file_perms;
allow dhcpc_t self:tcp_socket create_stream_socket_perms;
allow dhcpc_t self:udp_socket create_socket_perms;
allow dhcpc_t self:packet_socket create_socket_perms;
allow dhcpc_t self:netlink_generic_socket create_socket_perms;
allow dhcpc_t self:netlink_route_socket create_netlink_socket_perms;
allow dhcpc_t self:rawip_socket create_socket_perms;

allow dhcpc_t dhcp_etc_t:dir list_dir_perms;
read_lnk_files_pattern(dhcpc_t, dhcp_etc_t, dhcp_etc_t)
exec_files_pattern(dhcpc_t, dhcp_etc_t, dhcp_etc_t)

allow dhcpc_t dhcp_state_t:file read_file_perms;
manage_files_pattern(dhcpc_t, dhcpc_state_t, dhcpc_state_t)
filetrans_pattern(dhcpc_t, dhcp_state_t, dhcpc_state_t, file)
allow dhcpc_t dhcpc_state_t:file map;

# create pid file
manage_files_pattern(dhcpc_t, dhcpc_runtime_t, dhcpc_runtime_t)
create_dirs_pattern(dhcpc_t, dhcpc_runtime_t, dhcpc_runtime_t)
# Create /var/run/dhcpc directory (state directory), needed for /run/dhcpc
# Gets done through the dhcpcd-hooks
files_pid_filetrans(dhcpc_t, dhcpc_runtime_t, { file dir })

# Allow read/write to /etc/resolv.conf and /etc/ntp.conf. Note that any files
# in /etc created by dhcpcd will be labelled net_conf_t.
sysnet_manage_config(dhcpc_t)
files_etc_filetrans(dhcpc_t, net_conf_t, file)

# create temp files
manage_dirs_pattern(dhcpc_t, dhcpc_tmp_t, dhcpc_tmp_t)
manage_files_pattern(dhcpc_t, dhcpc_tmp_t, dhcpc_tmp_t)
files_tmp_filetrans(dhcpc_t, dhcpc_tmp_t, { file dir })

can_exec(dhcpc_t, dhcpc_exec_t)

kernel_read_system_state(dhcpc_t)
kernel_read_network_state(dhcpc_t)
kernel_search_network_sysctl(dhcpc_t)
kernel_read_kernel_sysctls(dhcpc_t)
kernel_request_load_module(dhcpc_t)
kernel_use_fds(dhcpc_t)
kernel_rw_net_sysctls(dhcpc_t)

corecmd_exec_bin(dhcpc_t)
corecmd_exec_shell(dhcpc_t)

corenet_all_recvfrom_unlabeled(dhcpc_t)
corenet_all_recvfrom_netlabel(dhcpc_t)
corenet_tcp_sendrecv_all_if(dhcpc_t)
corenet_raw_sendrecv_all_if(dhcpc_t)
corenet_udp_sendrecv_all_if(dhcpc_t)
corenet_tcp_sendrecv_all_nodes(dhcpc_t)
corenet_raw_sendrecv_all_nodes(dhcpc_t)
corenet_udp_sendrecv_all_nodes(dhcpc_t)
corenet_tcp_sendrecv_all_ports(dhcpc_t)
corenet_udp_sendrecv_all_ports(dhcpc_t)
corenet_tcp_bind_all_nodes(dhcpc_t)
corenet_udp_bind_all_nodes(dhcpc_t)
corenet_tcp_bind_dhcpc_port(dhcpc_t)
corenet_udp_bind_dhcpc_port(dhcpc_t)
corenet_udp_bind_all_unreserved_ports(dhcpc_t)
corenet_tcp_connect_all_ports(dhcpc_t)
corenet_sendrecv_dhcpd_client_packets(dhcpc_t)
corenet_sendrecv_all_server_packets(dhcpc_t)

dev_read_sysfs(dhcpc_t)
# for SSP:
dev_read_urand(dhcpc_t)

domain_use_interactive_fds(dhcpc_t)
domain_dontaudit_read_all_domains_state(dhcpc_t)

files_read_etc_files(dhcpc_t)
files_read_etc_runtime_files(dhcpc_t)
files_read_usr_files(dhcpc_t)
files_search_home(dhcpc_t)
files_search_var_lib(dhcpc_t)
files_dontaudit_search_locks(dhcpc_t)
files_getattr_generic_locks(dhcpc_t)
files_manage_var_files(dhcpc_t)

fs_getattr_all_fs(dhcpc_t)
fs_search_auto_mountpoints(dhcpc_t)
fs_search_cgroup_dirs(dhcpc_t)

term_dontaudit_use_all_ttys(dhcpc_t)
term_dontaudit_use_all_ptys(dhcpc_t)
term_dontaudit_use_unallocated_ttys(dhcpc_t)
term_dontaudit_use_generic_ptys(dhcpc_t)

init_rw_utmp(dhcpc_t)

logging_send_syslog_msg(dhcpc_t)

miscfiles_read_localization(dhcpc_t)
# dhclient reads /etc/ssl
miscfiles_read_generic_certs(dhcpc_t)

sysnet_run_ifconfig(dhcpc_t, dhcpc_roles)

userdom_use_user_terminals(dhcpc_t)
userdom_dontaudit_search_user_home_dirs(dhcpc_t)

ifdef(`distro_redhat', `
	files_exec_etc_files(dhcpc_t)
')

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(dhcpc_t)
	')
')

ifdef(`init_systemd',`
	init_rw_stream_sockets(dhcpc_t)
	init_read_state(dhcpc_t)
	init_stream_connect(dhcpc_t)
	init_get_all_units_status(dhcpc_t)
	init_search_units(dhcpc_t)
')

optional_policy(`
	avahi_domtrans(dhcpc_t)
')

optional_policy(`
	consoletype_run(dhcpc_t, dhcpc_roles)
')

optional_policy(`
	dbus_system_domain(dhcpc_t, dhcpc_exec_t)

	init_dbus_chat_script(dhcpc_t)

	optional_policy(`
		networkmanager_dbus_chat(dhcpc_t)
	')
')

optional_policy(`
	hostname_run(dhcpc_t, dhcpc_roles)
')

optional_policy(`
	hal_dontaudit_rw_dgram_sockets(dhcpc_t)
')

optional_policy(`
	hotplug_getattr_config_dirs(dhcpc_t)
	hotplug_search_config(dhcpc_t)

	ifdef(`distro_redhat',`
		logging_domtrans_syslog(dhcpc_t)
	')
')

optional_policy(`
	modutils_run(dhcpc_t, dhcpc_roles)
')

# for the dhcp client to run ping to check IP addresses
optional_policy(`
	netutils_run_ping(dhcpc_t, dhcpc_roles)
	netutils_run(dhcpc_t, dhcpc_roles)
')

optional_policy(`
	networkmanager_domtrans(dhcpc_t)
	networkmanager_read_pid_files(dhcpc_t)
	networkmanager_manage_lib_files(dhcpc_t)
	networkmanager_stream_connect(dhcpc_t)
')

optional_policy(`
	nis_read_ypbind_pid(dhcpc_t)
')

optional_policy(`
	nscd_initrc_domtrans(dhcpc_t)
	nscd_domtrans(dhcpc_t)
	nscd_read_pid(dhcpc_t)
')

optional_policy(`
	ntp_initrc_domtrans(dhcpc_t)
	ntp_read_drift_files(dhcpc_t)
	ntp_read_conf_files(dhcpc_t)
')

optional_policy(`
	pcmcia_stub(dhcpc_t)
	dev_rw_cardmgr(dhcpc_t)
')

optional_policy(`
	samba_manage_config(dhcpc_t)
')

optional_policy(`
	seutil_sigchld_newrole(dhcpc_t)
	seutil_dontaudit_search_config(dhcpc_t)
')

optional_policy(`
	udev_read_db(dhcpc_t)
')

optional_policy(`
	userdom_use_all_users_fds(dhcpc_t)
')

optional_policy(`
	vmware_append_log(dhcpc_t)
')

optional_policy(`
	kernel_read_xen_state(dhcpc_t)
	kernel_write_xen_state(dhcpc_t)
	xen_append_log(dhcpc_t)
	xen_dontaudit_rw_unix_stream_sockets(dhcpc_t)
')

########################################
#
# Ifconfig local policy
#

allow ifconfig_t self:capability { net_admin net_raw sys_admin sys_tty_config };
dontaudit ifconfig_t self:capability sys_module;
allow ifconfig_t self:process { transition signal_perms getsched setsched getsession getpgid setpgid getcap setcap share getattr noatsecure siginh rlimitinh dyntransition setkeycreate setsockcreate getrlimit };
allow ifconfig_t self:fd use;
allow ifconfig_t self:fifo_file rw_fifo_file_perms;
allow ifconfig_t self:sock_file read_sock_file_perms;
allow ifconfig_t self:socket create_socket_perms;
allow ifconfig_t self:unix_dgram_socket create_socket_perms;
allow ifconfig_t self:unix_stream_socket create_stream_socket_perms;
allow ifconfig_t self:unix_dgram_socket sendto;
allow ifconfig_t self:unix_stream_socket connectto;
allow ifconfig_t self:shm create_shm_perms;
allow ifconfig_t self:sem create_sem_perms;
allow ifconfig_t self:msgq create_msgq_perms;
allow ifconfig_t self:msg { send receive };
# Create UDP sockets, necessary when called from dhcpc
allow ifconfig_t self:udp_socket create_socket_perms;
# for /sbin/ip
allow ifconfig_t self:packet_socket create_socket_perms;
# generic netlink socket for iw
# socket(PF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_GENERIC) = 3
allow ifconfig_t self:netlink_socket create_socket_perms;
allow ifconfig_t self:netlink_generic_socket create_socket_perms;
allow ifconfig_t self:netlink_route_socket create_netlink_socket_perms;
allow ifconfig_t self:netlink_xfrm_socket create_netlink_socket_perms;
allow ifconfig_t self:tcp_socket { create ioctl };

kernel_use_fds(ifconfig_t)
kernel_read_system_state(ifconfig_t)
kernel_read_network_state(ifconfig_t)
kernel_request_load_module(ifconfig_t)
kernel_search_network_sysctl(ifconfig_t)
kernel_rw_net_sysctls(ifconfig_t)

corenet_rw_tun_tap_dev(ifconfig_t)

dev_read_sysfs(ifconfig_t)
# for IPSEC setup:
dev_read_urand(ifconfig_t)

domain_use_interactive_fds(ifconfig_t)

files_read_etc_files(ifconfig_t)
files_read_etc_runtime_files(ifconfig_t)

fs_getattr_xattr_fs(ifconfig_t)
fs_search_auto_mountpoints(ifconfig_t)

selinux_dontaudit_getattr_fs(ifconfig_t)

term_dontaudit_use_console(ifconfig_t)
term_dontaudit_use_all_ttys(ifconfig_t)
term_dontaudit_use_all_ptys(ifconfig_t)
term_dontaudit_use_ptmx(ifconfig_t)
term_dontaudit_use_generic_ptys(ifconfig_t)

files_dontaudit_read_root_files(ifconfig_t)

init_use_fds(ifconfig_t)
init_use_script_ptys(ifconfig_t)

logging_send_syslog_msg(ifconfig_t)

miscfiles_read_localization(ifconfig_t)

seutil_use_runinit_fds(ifconfig_t)

sysnet_dontaudit_rw_dhcpc_udp_sockets(ifconfig_t)

userdom_use_user_terminals(ifconfig_t)
userdom_use_all_users_fds(ifconfig_t)

ifdef(`distro_debian',`
	term_dontaudit_use_unallocated_ttys(ifconfig_t)
')

ifdef(`distro_ubuntu',`
	optional_policy(`
		unconfined_domain(ifconfig_t)
	')
')

ifdef(`hide_broken_symptoms',`
	optional_policy(`
		dev_dontaudit_rw_cardmgr(ifconfig_t)
	')

	optional_policy(`
		udev_dontaudit_rw_dgram_sockets(ifconfig_t)
	')
')

optional_policy(`
	devicekit_read_pid_files(ifconfig_t)
	devicekit_append_inherited_log_files(ifconfig_t)
')

optional_policy(`
	hal_dontaudit_rw_pipes(ifconfig_t)
	hal_dontaudit_rw_dgram_sockets(ifconfig_t)
')

optional_policy(`
	ipsec_write_pid(ifconfig_t)
	ipsec_setcontext_default_spd(ifconfig_t)
')

optional_policy(`
	networkmanager_dontaudit_use_wpa_cli_fds(ifconfig_t)
')

optional_policy(`
	modutils_domtrans(ifconfig_t)
')

optional_policy(`
	nis_use_ypbind(ifconfig_t)
')

optional_policy(`
	ppp_use_fds(ifconfig_t)
')

optional_policy(`
	unconfined_dontaudit_rw_pipes(ifconfig_t)
')

optional_policy(`
	vmware_append_log(ifconfig_t)
')

optional_policy(`
	kernel_read_xen_state(ifconfig_t)
	kernel_write_xen_state(ifconfig_t)
	xen_append_log(ifconfig_t)
	xen_dontaudit_rw_unix_stream_sockets(ifconfig_t)
')

ifdef(`distro_gentoo',`
	###########################################
	#
	# dhcp client policy
	#

	# Fixes bug 468874
	allow dhcpc_t self:rawip_socket create_socket_perms;

	# Fixes bug 530898
	allow dhcpc_t self:netlink_kobject_uevent_socket client_stream_socket_perms;
	# Also mentioned as AVCs in bug 530898. Not certain if this is needed but considering
	# the dhcpc_t use case we currently allow it
	allow dhcpc_t self:netlink_socket client_stream_socket_perms;

	# Allow dhcpcd to set its control sockets
	allow dhcpc_t dhcpc_var_run_t:sock_file manage_sock_file_perms;

	# Allow dhcpc to set hostname (/proc/sys/kernel/hostname)
	allow dhcpc_t self:capability sys_admin;
	kernel_rw_kernel_sysctl(dhcpc_t)

	# Fixes bug 468878
	files_pid_filetrans(dhcpc_t, dhcpc_var_run_t, sock_file)
	allow dhcpc_t self:unix_stream_socket { create_stream_socket_perms connectto };

	optional_policy(`
		resolvconf_client_domain(dhcpc_t)
	')

	#########################################
	#
	# dhcpc_script_t
	#

	# The purpose of the dhcpc_script_t domain is to handle the post-processing of
	# the dhcpcd ip renewal. dhcpcd (the tool) supports hooks for this, and I would
	# assume others do as well. With the dhcpc_script_t domain we can isolate the
	# privileges of the DHCP client itself from the hooks / flexibility that the developers
	# introduced.

	type dhcpc_script_t;
	domain_type(dhcpc_script_t)
	role dhcpc_roles types dhcpc_script_t;

	type dhcpc_script_exec_t;
	domain_entry_file(dhcpc_script_t, dhcpc_script_exec_t)

	type dhcpc_script_tmp_t;
	files_tmp_file(dhcpc_script_tmp_t)

	########################################
	#
	# dhcpc script policy
	#

	allow dhcpc_script_t self:fifo_file rw_fifo_file_perms;

	manage_files_pattern(dhcpc_script_t, dhcpc_script_tmp_t, dhcpc_script_tmp_t)
	files_tmp_filetrans(dhcpc_script_t, dhcpc_script_tmp_t, { file dir })

	manage_files_pattern(dhcpc_script_t, dhcpc_var_run_t, dhcpc_var_run_t)
	create_dirs_pattern(dhcpc_script_t, dhcpc_var_run_t, dhcpc_var_run_t)
	files_pid_filetrans(dhcpc_script_t, dhcpc_var_run_t, { file dir })

	kernel_read_network_state(dhcpc_script_t)
	kernel_read_system_state(dhcpc_script_t)

	corecmd_exec_bin(dhcpc_script_t)
	corecmd_exec_shell(dhcpc_script_t)

	files_read_etc_files(dhcpc_script_t)

	init_use_script_fds(dhcpc_script_t)
	init_use_script_ptys(dhcpc_script_t)

	# Perhaps sysnet_domtrans_dhcpc_script could be used instead and positioned in the dhcpc_t section
	domtrans_pattern(dhcpc_t, dhcpc_script_exec_t, dhcpc_script_t)

	sysnet_manage_config(dhcpc_script_t)

	optional_policy(`
		hostname_run(dhcpc_script_t, dhcpc_roles)
	')

	optional_policy(`
		ntp_manage_config(dhcpc_script_t)
	')

	optional_policy(`
		resolvconf_client_domain(dhcpc_script_t)
	')
')