aboutsummaryrefslogtreecommitdiff
blob: 724b334e1ee46fb5cd761c687687914d36e19531 (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
policy_module(udev, 1.24.2)

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

type udev_t;
type udev_exec_t;
type udev_helper_exec_t;
kernel_domtrans_to(udev_t, udev_exec_t)
domain_obj_id_change_exemption(udev_t)
domain_entry_file(udev_t, udev_helper_exec_t)
domain_interactive_fd(udev_t)
init_daemon_domain(udev_t, udev_exec_t)
init_named_socket_activation(udev_t, udev_var_run_t)

type udev_etc_t alias etc_udev_t;
files_config_file(udev_etc_t)

type udev_tbl_t alias udev_tdb_t;
files_type(udev_tbl_t)

type udev_rules_t;
files_type(udev_rules_t)

type udev_var_run_t;
files_pid_file(udev_var_run_t)
init_daemon_pid_file(udev_var_run_t, dir, "udev")

ifdef(`enable_mcs',`
	kernel_ranged_domtrans_to(udev_t, udev_exec_t, s0 - mcs_systemhigh)
	init_ranged_daemon_domain(udev_t, udev_exec_t, s0 - mcs_systemhigh)
')

########################################
#
# Local policy
#

allow udev_t self:capability { chown dac_override dac_read_search fowner fsetid mknod net_admin net_raw setgid setuid sys_admin sys_nice sys_nice sys_ptrace sys_rawio sys_resource };
dontaudit udev_t self:capability sys_tty_config;
allow udev_t self:capability2 { wake_alarm block_suspend };
allow udev_t self:process { transition signal_perms ptrace getsched setsched getsession getpgid setpgid getcap setcap share getattr setfscreate noatsecure siginh rlimitinh dyntransition execmem setkeycreate setsockcreate getrlimit };
allow udev_t self:fd use;
allow udev_t self:fifo_file rw_fifo_file_perms;
allow udev_t self:sock_file read_sock_file_perms;
allow udev_t self:shm create_shm_perms;
allow udev_t self:sem create_sem_perms;
allow udev_t self:msgq create_msgq_perms;
allow udev_t self:msg { send receive };
allow udev_t self:unix_stream_socket { listen accept };
allow udev_t self:unix_dgram_socket sendto;
allow udev_t self:unix_stream_socket connectto;
allow udev_t self:netlink_kobject_uevent_socket create_socket_perms;
allow udev_t self:netlink_generic_socket create_socket_perms;
allow udev_t self:rawip_socket create_socket_perms;

# for systemd-udevd to rename interfaces
allow udev_t self:netlink_route_socket nlmsg_write;

allow udev_t udev_exec_t:file write;
can_exec(udev_t, udev_exec_t)

allow udev_t udev_helper_exec_t:dir list_dir_perms;
can_exec(udev_t, udev_helper_exec_t)

# read udev config
allow udev_t udev_etc_t:file read_file_perms;

allow udev_t udev_tbl_t:file manage_file_perms;
dev_filetrans(udev_t, udev_tbl_t, file)

list_dirs_pattern(udev_t, udev_rules_t, udev_rules_t)
manage_files_pattern(udev_t, udev_rules_t, udev_rules_t)
manage_lnk_files_pattern(udev_t, udev_rules_t, udev_rules_t)

manage_dirs_pattern(udev_t, udev_var_run_t, udev_var_run_t)
manage_files_pattern(udev_t, udev_var_run_t, udev_var_run_t)
manage_lnk_files_pattern(udev_t, udev_var_run_t, udev_var_run_t)
manage_sock_files_pattern(udev_t, udev_var_run_t, udev_var_run_t)
files_pid_filetrans(udev_t, udev_var_run_t, dir, "udev")
files_pid_filetrans(udev_t, udev_var_run_t, dir, "console-setup")

kernel_load_module(udev_t)
kernel_read_system_state(udev_t)
kernel_request_load_module(udev_t)
kernel_getattr_core_if(udev_t)
kernel_use_fds(udev_t)
kernel_read_device_sysctls(udev_t)
kernel_read_hotplug_sysctls(udev_t)
kernel_read_modprobe_sysctls(udev_t)
kernel_read_kernel_sysctls(udev_t)
kernel_rw_hotplug_sysctls(udev_t)
kernel_rw_unix_dgram_sockets(udev_t)
kernel_dgram_send(udev_t)
kernel_signal(udev_t)
kernel_search_debugfs(udev_t)
kernel_search_key(udev_t)

#https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=235182
kernel_rw_net_sysctls(udev_t)
kernel_read_crypto_sysctls(udev_t)
kernel_read_network_state(udev_t)
kernel_read_software_raid_state(udev_t)
kernel_dontaudit_search_unlabeled(udev_t)

corecmd_exec_all_executables(udev_t)

dev_rw_sysfs(udev_t)
dev_manage_all_dev_nodes(udev_t)
dev_rw_generic_files(udev_t)
dev_delete_generic_files(udev_t)
dev_search_usbfs(udev_t)
dev_relabel_all_dev_nodes(udev_t)
# udev_node.c/node_symlink() symlink labels are explicitly
# preserved, instead of short circuiting the relabel
dev_relabel_generic_symlinks(udev_t)
dev_manage_generic_symlinks(udev_t)

domain_read_all_domains_state(udev_t)
domain_dontaudit_ptrace_all_domains(udev_t) #pidof triggers these

files_read_usr_files(udev_t)
files_read_etc_runtime_files(udev_t)
files_read_etc_files(udev_t)
files_read_kernel_modules(udev_t)
files_exec_etc_files(udev_t)
files_getattr_generic_locks(udev_t)
files_search_mnt(udev_t)

fs_getattr_all_fs(udev_t)
fs_list_inotifyfs(udev_t)
fs_read_cgroup_files(udev_t)
fs_rw_anon_inodefs_files(udev_t)
fs_search_tracefs(udev_t)

mcs_ptrace_all(udev_t)

mls_file_read_all_levels(udev_t)
mls_file_write_all_levels(udev_t)
mls_file_upgrade(udev_t)
mls_file_downgrade(udev_t)
mls_process_write_all_levels(udev_t)

selinux_get_fs_mount(udev_t)
selinux_validate_context(udev_t)
selinux_compute_access_vector(udev_t)
selinux_compute_create_context(udev_t)
selinux_compute_relabel_context(udev_t)
selinux_compute_user_contexts(udev_t)

auth_read_pam_console_data(udev_t)
auth_domtrans_pam_console(udev_t)
auth_use_nsswitch(udev_t)

init_read_utmp(udev_t)
init_domtrans_script(udev_t)
# systemd-udevd searches /run/systemd
init_search_run(udev_t)
init_dontaudit_write_utmp(udev_t)
init_getattr_initctl(udev_t)
init_start_all_units(udev_t)
init_stop_all_units(udev_t)
# for hdparm init script run by udev
init_get_script_status(udev_t)

logging_search_logs(udev_t)
logging_send_syslog_msg(udev_t)
logging_send_audit_msgs(udev_t)

miscfiles_read_localization(udev_t)
miscfiles_read_hwdata(udev_t)

modutils_domtrans(udev_t)
modutils_read_module_config(udev_t)
# read modules.inputmap:
modutils_read_module_deps(udev_t)
modutils_read_module_objects(udev_t)

seutil_read_config(udev_t)
seutil_read_default_contexts(udev_t)
seutil_read_file_contexts(udev_t)
seutil_domtrans_setfiles(udev_t)

sysnet_domtrans_ifconfig(udev_t)
sysnet_domtrans_dhcpc(udev_t)
sysnet_rw_dhcp_config(udev_t)
sysnet_read_dhcpc_pid(udev_t)
sysnet_delete_dhcpc_pid(udev_t)
sysnet_signal_dhcpc(udev_t)
sysnet_manage_config(udev_t)
sysnet_etc_filetrans_config(udev_t)

userdom_dontaudit_search_user_home_content(udev_t)

ifdef(`distro_debian',`
	# for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=851933
	files_read_default_files(udev_t)

	files_pid_filetrans(udev_t, udev_var_run_t, dir, "xen-hotplug")

	optional_policy(`
		# for /usr/lib/avahi/avahi-daemon-check-dns.sh
		kernel_read_vm_sysctls(udev_t)
		corenet_udp_bind_generic_node(udev_t)
		miscfiles_read_generic_certs(udev_t)
		avahi_create_pid_dirs(udev_t)
		avahi_initrc_domtrans(udev_t)
		avahi_manage_pid_files(udev_t)
		avahi_setattr_pid_dirs(udev_t)
		avahi_filetrans_pid(udev_t, dir, "avahi-daemon")
	')
')

ifdef(`distro_gentoo',`
	# during boot, init scripts use /dev/.rcsysinit
	# existence to determine if we are in early booting
	init_getattr_script_status_files(udev_t)
')

ifdef(`distro_redhat',`
	fs_manage_tmpfs_dirs(udev_t)
	fs_manage_tmpfs_files(udev_t)
	fs_manage_tmpfs_symlinks(udev_t)
	fs_manage_tmpfs_sockets(udev_t)
	fs_manage_tmpfs_blk_files(udev_t)
	fs_manage_tmpfs_chr_files(udev_t)
	fs_relabel_tmpfs_blk_file(udev_t)
	fs_relabel_tmpfs_chr_file(udev_t)

	term_search_ptys(udev_t)

	# for arping used for static IP addresses on PCMCIA ethernet
	netutils_domtrans(udev_t)

	optional_policy(`
		unconfined_domain(udev_t)
	')
')

ifdef(`init_systemd',`
	files_search_kernel_modules(udev_t)

	fs_read_cgroup_files(udev_t)

	init_dgram_send(udev_t)
	init_get_generic_units_status(udev_t)
	init_stream_connect(udev_t)

	systemd_read_hwdb(udev_t)
	systemd_read_logind_sessions_files(udev_t)
	systemd_read_logind_pids(udev_t)

	optional_policy(`
		init_dbus_chat(udev_t)
	')
',`
	fs_manage_tmpfs_dirs(udev_t)
	fs_manage_tmpfs_files(udev_t)
')

optional_policy(`
	alsa_domtrans(udev_t)
	alsa_read_lib(udev_t)
	alsa_read_config(udev_t)
')

optional_policy(`
	bluetooth_domtrans(udev_t)
')

optional_policy(`
	brctl_domtrans(udev_t)
')

optional_policy(`
	clock_domtrans(udev_t)
')

optional_policy(`
	consoletype_exec(udev_t)
')

optional_policy(`
	consolekit_read_pid_files(udev_t)
')

optional_policy(`
	cups_domtrans_config(udev_t)
	cups_domtrans_hplip(udev_t)
')

optional_policy(`
	dbus_system_bus_client(udev_t)
	dbus_use_system_bus_fds(udev_t)

	optional_policy(`
		consolekit_dbus_chat(udev_t)
	')
')

optional_policy(`
	devicekit_read_pid_files(udev_t)
	devicekit_dgram_send(udev_t)
')

optional_policy(`
	fstools_domtrans(udev_t)
')

optional_policy(`
	hal_dgram_send(udev_t)

	ifdef(`hide_broken_symptoms',`
		hal_dontaudit_rw_dgram_sockets(udev_t)
	')
')

optional_policy(`
	hotplug_read_config(udev_t)
	# usb.agent searches /var/run/usb
	hotplug_search_pids(udev_t)
')

optional_policy(`
	iptables_domtrans(udev_t)
')

optional_policy(`
	lvm_domtrans(udev_t)
')

optional_policy(`
	mount_domtrans(udev_t)
')

optional_policy(`
	openct_read_pid_files(udev_t)
	openct_domtrans(udev_t)
')

optional_policy(`
	pcscd_read_pid_files(udev_t)
	pcscd_domtrans(udev_t)
')

optional_policy(`
	raid_domtrans_mdadm(udev_t)
')

optional_policy(`
	unconfined_signal(udev_t)
')

optional_policy(`
	vbetool_domtrans(udev_t)
')

optional_policy(`
	# for systemd-udevd when starting xen domu
	virt_read_config(udev_t)
')

optional_policy(`
	kernel_write_xen_state(udev_t)
	kernel_read_xen_state(udev_t)
	xen_manage_log(udev_t)
	xen_read_image_files(udev_t)
	fs_manage_xenfs_files(udev_t)
')

optional_policy(`
	xserver_read_xdm_pid(udev_t)
')

ifdef(`distro_gentoo',`
	#################################
	#
	# local udev_t policy
	#
	allow udev_t self:capability2 block_suspend;
	allow udev_t udev_tbl_t:dir relabelto;

	# needed for predictable network interfaces naming
	allow udev_t self:netlink_route_socket rw_netlink_socket_perms;
	# needed for crda, bug #538110
	allow udev_t self:netlink_socket create_socket_perms;

	manage_dirs_pattern(udev_t, udev_tbl_t, udev_tbl_t)
	manage_files_pattern(udev_t, udev_tbl_t, udev_tbl_t)
	manage_lnk_files_pattern(udev_t, udev_tbl_t, udev_tbl_t)

	kernel_load_module(udev_t)

	files_read_etc_files(udev_t)
	files_read_etc_runtime_files(udev_t)
	files_read_kernel_modules(udev_t)
	files_read_usr_files(udev_t)
	kernel_dontaudit_search_unlabeled(udev_t)

	udev_pid_filetrans_db(udev_t, dir, "data")

	init_domtrans_script(udev_t)
')