aboutsummaryrefslogtreecommitdiff
blob: 66d22279c8be9af8b6c42c674ca11ac1d58982f4 (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
policy_module(lvm, 1.22.0)

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

type clvmd_t;
type clvmd_exec_t;
init_daemon_domain(clvmd_t, clvmd_exec_t)

type clvmd_initrc_exec_t;
init_script_file(clvmd_initrc_exec_t)

type clvmd_var_run_t;
files_pid_file(clvmd_var_run_t)

type lvm_t;
type lvm_exec_t;
init_system_domain(lvm_t, lvm_exec_t)
init_named_socket_activation(lvm_t, lvm_var_run_t)
# needs privowner because it assigns the identity system_u to device nodes
# but runs as the identity of the sysadmin
domain_obj_id_change_exemption(lvm_t)
role system_r types lvm_t;

type lvm_etc_t;
files_type(lvm_etc_t)

type lvm_lock_t;
files_lock_file(lvm_lock_t)

type lvm_metadata_t;
files_type(lvm_metadata_t)

type lvm_unit_t;
init_unit_file(lvm_unit_t)

type lvm_var_lib_t;
files_type(lvm_var_lib_t)

type lvm_var_run_t;
files_pid_file(lvm_var_run_t)

type lvm_tmp_t;
files_tmp_file(lvm_tmp_t)

########################################
#
# Cluster LVM daemon local policy
#

allow clvmd_t self:capability { chown ipc_lock mknod sys_admin sys_nice };
dontaudit clvmd_t self:capability sys_tty_config;
allow clvmd_t self:process { signal_perms setsched };
dontaudit clvmd_t self:process ptrace;
allow clvmd_t self:socket create_socket_perms;
allow clvmd_t self:fifo_file rw_fifo_file_perms;
allow clvmd_t self:unix_stream_socket { connectto create_stream_socket_perms };
allow clvmd_t self:tcp_socket create_stream_socket_perms;
allow clvmd_t self:udp_socket create_socket_perms;

manage_files_pattern(clvmd_t, clvmd_var_run_t, clvmd_var_run_t)
files_pid_filetrans(clvmd_t, clvmd_var_run_t, file)

read_files_pattern(clvmd_t, lvm_metadata_t, lvm_metadata_t)

kernel_read_kernel_sysctls(clvmd_t)
kernel_read_system_state(clvmd_t)
kernel_list_proc(clvmd_t)
kernel_read_proc_symlinks(clvmd_t)
kernel_search_debugfs(clvmd_t)
kernel_dontaudit_getattr_core_if(clvmd_t)

corecmd_exec_shell(clvmd_t)
corecmd_getattr_bin_files(clvmd_t)

corenet_all_recvfrom_unlabeled(clvmd_t)
corenet_all_recvfrom_netlabel(clvmd_t)
corenet_tcp_sendrecv_generic_if(clvmd_t)
corenet_udp_sendrecv_generic_if(clvmd_t)
corenet_raw_sendrecv_generic_if(clvmd_t)
corenet_tcp_sendrecv_generic_node(clvmd_t)
corenet_udp_sendrecv_generic_node(clvmd_t)
corenet_raw_sendrecv_generic_node(clvmd_t)
corenet_tcp_sendrecv_all_ports(clvmd_t)
corenet_udp_sendrecv_all_ports(clvmd_t)
corenet_tcp_bind_generic_node(clvmd_t)
corenet_tcp_bind_reserved_port(clvmd_t)
corenet_dontaudit_tcp_bind_all_reserved_ports(clvmd_t)
corenet_sendrecv_generic_server_packets(clvmd_t)

dev_read_sysfs(clvmd_t)
dev_manage_generic_symlinks(clvmd_t)
dev_relabel_generic_dev_dirs(clvmd_t)
dev_manage_generic_blk_files(clvmd_t)
dev_manage_generic_chr_files(clvmd_t)
dev_rw_lvm_control(clvmd_t)
dev_dontaudit_getattr_all_blk_files(clvmd_t)
dev_dontaudit_getattr_all_chr_files(clvmd_t)
dev_create_generic_dirs(clvmd_t)
dev_delete_generic_dirs(clvmd_t)

files_read_etc_files(clvmd_t)
files_list_usr(clvmd_t)

fs_getattr_all_fs(clvmd_t)
fs_search_auto_mountpoints(clvmd_t)
fs_dontaudit_list_tmpfs(clvmd_t)
fs_dontaudit_read_removable_files(clvmd_t)
fs_rw_anon_inodefs_files(clvmd_t)

storage_dontaudit_getattr_removable_dev(clvmd_t)
storage_manage_fixed_disk(clvmd_t)
storage_dev_filetrans_fixed_disk(clvmd_t)
storage_relabel_fixed_disk(clvmd_t)
storage_raw_read_fixed_disk(clvmd_t)

domain_use_interactive_fds(clvmd_t)

auth_use_nsswitch(clvmd_t)

init_dontaudit_getattr_initctl(clvmd_t)

logging_send_syslog_msg(clvmd_t)

miscfiles_read_localization(clvmd_t)

seutil_sigchld_newrole(clvmd_t)
seutil_read_config(clvmd_t)
seutil_read_file_contexts(clvmd_t)
seutil_search_default_contexts(clvmd_t)

userdom_dontaudit_use_unpriv_user_fds(clvmd_t)
userdom_dontaudit_search_user_home_dirs(clvmd_t)

lvm_domtrans(clvmd_t)
lvm_read_config(clvmd_t)

ifdef(`distro_redhat',`
	optional_policy(`
		unconfined_domain(clvmd_t)
	')
')

optional_policy(`
	ccs_stream_connect(clvmd_t)
')

optional_policy(`
	gpm_dontaudit_getattr_gpmctl(clvmd_t)
')

optional_policy(`
	ricci_dontaudit_rw_modcluster_pipes(clvmd_t)
	ricci_dontaudit_use_modcluster_fds(clvmd_t)
')

optional_policy(`
	udev_read_db(clvmd_t)
')

########################################
#
# LVM Local policy
#

# DAC overrides and mknod for modifying /dev entries (vgmknodes)
# rawio needed for dmraid
# net_admin for multipath
allow lvm_t self:capability { chown dac_override fowner ipc_lock mknod net_admin sys_admin sys_nice sys_rawio sys_resource };
dontaudit lvm_t self:capability sys_tty_config;
allow lvm_t self:process { sigchld sigkill sigstop signull signal setfscreate };
# LVM will complain a lot if it cannot set its priority.
allow lvm_t self:process setsched;
allow lvm_t self:file rw_file_perms;
allow lvm_t self:fifo_file manage_fifo_file_perms;
allow lvm_t self:unix_dgram_socket create_socket_perms;
allow lvm_t self:netlink_kobject_uevent_socket create_socket_perms;
allow lvm_t self:sem create_sem_perms;
# gt: the following is for sockets in the AF_ALG namespace (userspace interface to the kernel Crypto API)
allow lvm_t self:socket create_stream_socket_perms;

allow lvm_t self:unix_stream_socket { connectto create_stream_socket_perms };
allow lvm_t clvmd_t:unix_stream_socket { connectto rw_socket_perms };

manage_dirs_pattern(lvm_t, lvm_tmp_t, lvm_tmp_t)
manage_files_pattern(lvm_t, lvm_tmp_t, lvm_tmp_t)
files_tmp_filetrans(lvm_t, lvm_tmp_t, { file dir })

# /lib/lvm-<version> holds the actual LVM binaries (and symlinks)
read_files_pattern(lvm_t, lvm_exec_t, lvm_exec_t)
read_lnk_files_pattern(lvm_t, lvm_exec_t, lvm_exec_t)

# LVM is split into many individual binaries
can_exec(lvm_t, lvm_exec_t)

# Creating lock files
manage_files_pattern(lvm_t, lvm_lock_t, lvm_lock_t)
create_dirs_pattern(lvm_t, lvm_lock_t, lvm_lock_t)
files_lock_filetrans(lvm_t, lvm_lock_t, file)
files_lock_filetrans(lvm_t, lvm_lock_t, dir, "lvm")

manage_dirs_pattern(lvm_t, lvm_var_lib_t, lvm_var_lib_t)
manage_files_pattern(lvm_t, lvm_var_lib_t, lvm_var_lib_t)
files_var_lib_filetrans(lvm_t, lvm_var_lib_t, { dir file })

manage_dirs_pattern(lvm_t, lvm_var_run_t, lvm_var_run_t)
manage_files_pattern(lvm_t, lvm_var_run_t, lvm_var_run_t)
manage_sock_files_pattern(lvm_t, lvm_var_run_t, lvm_var_run_t)
files_pid_filetrans(lvm_t, lvm_var_run_t, { file sock_file })

read_files_pattern(lvm_t, lvm_etc_t, lvm_etc_t)
allow lvm_t lvm_etc_t:file map;

read_lnk_files_pattern(lvm_t, lvm_etc_t, lvm_etc_t)
# Map for vgchange on /etc/lvm/backup/ files
allow lvm_t lvm_metadata_t:file map;
# Write to /etc/lvm, /etc/lvmtab, /etc/lvmtab.d
manage_files_pattern(lvm_t, lvm_metadata_t, lvm_metadata_t)
filetrans_pattern(lvm_t, lvm_etc_t, lvm_metadata_t, file)
files_etc_filetrans(lvm_t, lvm_metadata_t, file)
files_search_mnt(lvm_t)

kernel_request_load_module(lvm_t)
kernel_get_sysvipc_info(lvm_t)
kernel_read_system_state(lvm_t)
# Read system variables in /proc/sys
kernel_read_kernel_sysctls(lvm_t)
# for when /usr is not mounted:
kernel_dontaudit_search_unlabeled(lvm_t)
# it has no reason to need this
kernel_dontaudit_getattr_core_if(lvm_t)
kernel_use_fds(lvm_t)
# for systemd-cryptsetup
kernel_read_crypto_sysctls(lvm_t)
kernel_search_debugfs(lvm_t)

corecmd_exec_bin(lvm_t)
corecmd_exec_shell(lvm_t)

dev_create_generic_chr_files(lvm_t)
dev_delete_generic_dirs(lvm_t)
dev_read_rand(lvm_t)
dev_read_urand(lvm_t)
dev_rw_lvm_control(lvm_t)
dev_manage_generic_symlinks(lvm_t)
dev_relabel_generic_dev_dirs(lvm_t)
dev_manage_generic_blk_files(lvm_t)
# Read /sys/block. Device mapper metadata is kept there.
# Write read_ahead_kb
dev_rw_sysfs(lvm_t)
# cjp: this has no effect since LVM does not
# have lnk_file relabelto for anything else.
# perhaps this should be blk_files?
dev_relabel_generic_symlinks(lvm_t)
# LVM (vgscan) scans for devices by stating every file in /dev and applying a regex...
dev_dontaudit_read_all_chr_files(lvm_t)
dev_dontaudit_read_all_blk_files(lvm_t)
dev_dontaudit_getattr_generic_chr_files(lvm_t)
dev_dontaudit_getattr_generic_blk_files(lvm_t)
dev_dontaudit_getattr_generic_pipes(lvm_t)
dev_create_generic_dirs(lvm_t)
# the following one is needed by cryptsetup
dev_getattr_fs(lvm_t)
# for systemd-cryptsetup
dev_write_kmsg(lvm_t)

domain_use_interactive_fds(lvm_t)
domain_read_all_domains_state(lvm_t)

files_read_usr_files(lvm_t)
files_read_etc_files(lvm_t)
files_read_etc_runtime_files(lvm_t)

fs_getattr_xattr_fs(lvm_t)
fs_search_auto_mountpoints(lvm_t)
fs_list_tmpfs(lvm_t)
fs_read_tmpfs_symlinks(lvm_t)
fs_dontaudit_read_removable_files(lvm_t)
fs_dontaudit_getattr_tmpfs_files(lvm_t)
fs_rw_anon_inodefs_files(lvm_t)

mls_file_read_all_levels(lvm_t)
mls_file_write_to_clearance(lvm_t)

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

storage_relabel_fixed_disk(lvm_t)
storage_dontaudit_read_removable_device(lvm_t)
# LVM creates block devices in /dev/mapper or /dev/<vg>
# depending on its version
# LVM(2) needs to create directories (/dev/mapper, /dev/<vg>)
# and links from /dev/<vg> to /dev/mapper/<vg>-<lv>
# cjp: needs to create an interface here for fixed disk create
storage_dev_filetrans_fixed_disk(lvm_t)
# Access raw devices and old /dev/lvm (c 109,0).  Is this needed?
storage_manage_fixed_disk(lvm_t)

term_use_all_terms(lvm_t)

init_use_fds(lvm_t)
init_dontaudit_getattr_initctl(lvm_t)
init_use_script_ptys(lvm_t)
init_read_script_state(lvm_t)
init_read_script_tmp_files(lvm_t)
# for systemd-cryptsetup to talk to /run/systemd/journal/socket
init_stream_connect(lvm_t)

logging_send_syslog_msg(lvm_t)

miscfiles_read_localization(lvm_t)

seutil_read_config(lvm_t)
seutil_read_file_contexts(lvm_t)
seutil_search_default_contexts(lvm_t)
seutil_sigchld_newrole(lvm_t)

userdom_use_inherited_user_terminals(lvm_t)

ifdef(`init_systemd',`
	init_rw_stream_sockets(lvm_t)

	fs_manage_hugetlbfs_dirs(lvm_t)
')

ifdef(`distro_redhat',`
	# this is from the initrd:
	kernel_rw_unlabeled_dirs(lvm_t)

	optional_policy(`
		unconfined_domain(lvm_t)
	')
')

optional_policy(`
	bootloader_rw_tmp_files(lvm_t)
')

optional_policy(`
	ccs_stream_connect(lvm_t)
')

optional_policy(`
	dpkg_script_rw_pipes(lvm_t)
')

optional_policy(`
	gpm_dontaudit_getattr_gpmctl(lvm_t)
')

optional_policy(`
	dbus_system_bus_client(lvm_t)

	optional_policy(`
		hal_dbus_chat(lvm_t)
	')
')

optional_policy(`
	modutils_domtrans(lvm_t)
')

optional_policy(`
	rpm_manage_script_tmp_files(lvm_t)
')

optional_policy(`
	udev_read_db(lvm_t)
	udev_read_pid_files(lvm_t)
')

optional_policy(`
	virt_manage_images(lvm_t)
')

optional_policy(`
	xen_append_log(lvm_t)
	xen_dontaudit_rw_unix_stream_sockets(lvm_t)
')

ifdef(`distro_gentoo',`
	#############################
	#
	# Local lvm policy
	#

	# cryptsetup support bug 530918
	allow lvm_t self:socket create_stream_socket_perms;

	create_dirs_pattern(lvm_t, lvm_etc_t, lvm_metadata_t)
	# Bug 529430 comment 6
	create_dirs_pattern(lvm_t, lvm_etc_t, lvm_etc_t)
	# Bug 529430 comment 8
	manage_fifo_files_pattern(lvm_t, lvm_var_run_t, lvm_var_run_t)

	# Bug 615300
	init_read_script_pipes(lvm_t)

	filetrans_pattern(lvm_t, lvm_etc_t, lvm_metadata_t, dir, "cache")

	kernel_request_load_module(lvm_t)

	dev_filetrans(lvm_t, lvm_lock_t, dir, ".lvm")

	optional_policy(`
		udev_read_pid_files(lvm_t)
	')
')