-
Notifications
You must be signed in to change notification settings - Fork 91
/
container_selinux.8
466 lines (347 loc) · 17.3 KB
/
container_selinux.8
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
.TH "container_selinux" "8" "24-04-25" "container" "SELinux Policy container"
.SH "NAME"
container_selinux \- Security Enhanced Linux Policy for the container processes
.SH "DESCRIPTION"
Security-Enhanced Linux secures the container processes via flexible mandatory access control.
The container processes execute with the container_t SELinux type. You can check if you have these processes running by executing the \fBps\fP command with the \fB\-Z\fP qualifier.
For example:
.B ps -eZ | grep container_t
.SH PROCESS TYPES
SELinux defines process types (domains) for each process running on the system
.PP
You can see the context of a process using the \fB\-Z\fP option to \fBps\bP
.PP
Policy governs the access confined processes have to files.
SELinux container policy is very flexible allowing users to setup their container processes in as secure a method as possible.
.PP
The following process types are defined for container:
.EX
.B container_runtime_t, container_auth_t, container_userns_t, container_logreader_t, container_logwriter_t, container_kvm_t, container_init_t, container_engine_t, container_device_t, container_device_plugin_t, container_device_plugin_init_t, container_user_t, container_t
.EE
.PP
Note:
.B semanage permissive -a container_t
can be used to make the process type container_t permissive. SELinux does not deny access to permissive process types, but the AVC (SELinux denials) messages are still generated.
.SH "MCS Constrained"
The SELinux process type container_t is an MCS (Multi Category Security) constrained type. Sometimes this separation is referred to as sVirt. These types are usually used for securing multi-tenant environments, such as virtualization, containers or separation of users. The tools used to launch MCS types, pick out a different MCS label for each process group.
For example one process might be launched with container_t:s0:c1,c2, and another process launched with container_t:s0:c3,c4. The SELinux kernel only allows these processes can only write to content with a matching MCS label, or a MCS Label of s0. A process running with the MCS level of s0:c1,c2 is not allowed to write to content with the MCS label of s0:c3,c4
.SH BOOLEANS
SELinux policy is customizable based on least access required. container policy is extremely flexible and has several booleans that allow you to manipulate the policy and run container with the tightest access possible.
.PP
If you want to deny any process from ptracing or debugging any other processes, you must turn on the deny_ptrace boolean. Disabled by default.
.EX
.B setsebool -P deny_ptrace 1
.EE
.PP
If you want to allow sandbox containers to use all capabilities, you must turn on the virt_sandbox_use_all_caps boolean. Enabled by default.
.EX
.B setsebool -P virt_sandbox_use_all_caps 1
.EE
.PP
If you want to allow sandbox containers to send audit messages, you must turn on the virt_sandbox_use_audit boolean. Enabled by default.
.EX
.B setsebool -P virt_sandbox_use_audit 1
.EE
.PP
If you want to allow sandbox containers to use netlink system calls, you must turn on the virt_sandbox_use_netlink boolean. Disabled by default.
.EX
.B setsebool -P virt_sandbox_use_netlink 1
.EE
.PP
If you want to allow sandbox containers to use sys_admin system calls, for example mount, you must turn on the virt_sandbox_use_sys_admin boolean. Disabled by default.
.EX
.B setsebool -P virt_sandbox_use_sys_admin 1
.EE
.SH PORT TYPES
SELinux defines port types to represent TCP and UDP ports.
.PP
You can see the types associated with a port by using the following command:
.B semanage port -l
.PP
Policy governs the access confined processes have to these ports.
SELinux container policy is very flexible allowing users to setup their container processes in as secure a method as possible.
.PP
The following port types are defined for container:
.EX
.TP 5
.B container_port_t
.TP 10
.EE
.SH "MANAGED FILES"
The SELinux process type container_t can manage files labeled with the following file types. The paths listed are the default paths for these file types. Note the processes UID still need to have DAC permissions.
.br
.B bpf_t
/sys/fs/bpf
.br
.br
.B cifs_t
.br
.B container_file_t
/srv/containers(/.*)?
.br
/var/lib/origin(/.*)?
.br
/var/lib/rkt/cas(/.*)?
.br
/var/lib/nerdctl/[^/]*/volumes(/.*)?
.br
/var/lib/buildkit/[^/]*/snapshots(/.*)?
.br
/var/srv/containers(/.*)?
.br
/var/lib/containerd/[^/]*/snapshots(/.*)?
.br
/var/lib/kubernetes/pods(/.*)?
.br
/opt/local-path-provisioner(/.*)?
.br
/var/local-path-provisioner(/.*)?
.br
/var/lib/containers/storage/volumes/[^/]*/.*
.br
/var/lib/kubelet/pod-resources/kubelet.sock
.br
/home/[^/]+/\.local/share/containers/storage/volumes/[^/]*/.*
.br
.br
.B ecryptfs_t
/home/[^/]+/\.Private(/.*)?
.br
/home/[^/]+/\.ecryptfs(/.*)?
.br
.br
.B fs_t
.br
.B fusefs_t
/run/user/[0-9]+/gvfs
.br
.br
.B hugetlbfs_t
/dev/hugepages
.br
/usr/lib/udev/devices/hugepages
.br
.br
.B nfs_t
.br
.B onload_fs_t
.br
.B svirt_home_t
/home/[^/]+/\.libvirt/qemu(/.*)?
.br
/home/[^/]+/\.cache/libvirt/qemu(/.*)?
.br
/home/[^/]+/\.config/libvirt/qemu(/.*)?
.br
/home/[^/]+/\.local/share/libvirt/boot(/.*)?
.br
/home/[^/]+/\.local/share/libvirt/images(/.*)?
.br
/home/[^/]+/\.local/share/gnome-boxes/images(/.*)?
.br
.SH FILE CONTEXTS
SELinux requires files to have an extended attribute to define the file type.
.PP
You can see the context of a file using the \fB\-Z\fP option to \fBls\bP
.PP
Policy governs the access confined processes have to these files.
SELinux container policy is very flexible allowing users to setup their container processes in as secure a method as possible.
.PP
.PP
.B EQUIVALENCE DIRECTORIES
.PP
container policy stores data with multiple different file context types under the /var/lib/buildkit directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/buildkit /srv/buildkit
.br
.B restorecon -R -v /srv/buildkit
.PP
.PP
container policy stores data with multiple different file context types under the /var/lib/containerd directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/containerd /srv/containerd
.br
.B restorecon -R -v /srv/containerd
.PP
.PP
container policy stores data with multiple different file context types under the /var/lib/containers directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/containers /srv/containers
.br
.B restorecon -R -v /srv/containers
.PP
.PP
container policy stores data with multiple different file context types under the /var/lib/docker directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/docker /srv/docker
.br
.B restorecon -R -v /srv/docker
.PP
.PP
container policy stores data with multiple different file context types under the /var/lib/kubelet directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/kubelet /srv/kubelet
.br
.B restorecon -R -v /srv/kubelet
.PP
.PP
container policy stores data with multiple different file context types under the /var/lib/nerdctl directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/nerdctl /srv/nerdctl
.br
.B restorecon -R -v /srv/nerdctl
.PP
.PP
container policy stores data with multiple different file context types under the /var/lib/ocid directory. If you would like to store the data in a different directory you can use the semanage command to create an equivalence mapping. If you wanted to store this data under the /srv directory you would execute the following command:
.PP
.B semanage fcontext -a -e /var/lib/ocid /srv/ocid
.br
.B restorecon -R -v /srv/ocid
.PP
.PP
.B STANDARD FILE CONTEXT
SELinux defines the file context types for the container, if you wanted to
store files with these types in a different paths, you need to execute the semanage command to specify alternate labeling and then use restorecon to put the labels on disk.
.B semanage fcontext -a -t container_var_lib_t '/srv/container/content(/.*)?'
.br
.B restorecon -R -v /srv/mycontainer_content
Note: SELinux often uses regular expressions to specify labels that match multiple files.
.I The following file types are defined for container:
.EX
.PP
.B container_auth_exec_t
.EE
- Set files with the container_auth_exec_t type, if you want to transition an executable to the container_auth_t domain.
.br
.TP 5
Paths:
/usr/s?bin/docker-novolume-plugin, /usr/lib/docker/docker-novolume-plugin
.EX
.PP
.B container_config_t
.EE
- Set files with the container_config_t type, if you want to treat the files as container configuration data, usually stored under the /etc directory.
.br
.TP 5
Paths:
/etc/crio(/.*)?, /etc/docker(/.*)?, /etc/buildkit(/.*)?, /etc/containerd(/.*)?, /etc/docker-latest(/.*)?
.EX
.PP
.B container_file_t
.EE
- Set files with the container_file_t type, if you want to treat the files as container content.
.br
.TP 5
Paths:
/srv/containers(/.*)?, /var/lib/origin(/.*)?, /var/lib/rkt/cas(/.*)?, /var/lib/nerdctl/[^/]*/volumes(/.*)?, /var/lib/buildkit/[^/]*/snapshots(/.*)?, /var/srv/containers(/.*)?, /var/lib/containerd/[^/]*/snapshots(/.*)?, /var/lib/kubernetes/pods(/.*)?, /opt/local-path-provisioner(/.*)?, /var/local-path-provisioner(/.*)?, /var/lib/containers/storage/volumes/[^/]*/.*, /var/lib/kubelet/pod-resources/kubelet.sock, /home/[^/]+/\.local/share/containers/storage/volumes/[^/]*/.*
.EX
.PP
.B container_home_t
.EE
- Set files with the container_home_t type, if you want to store container files in the users home directory.
.EX
.PP
.B container_kvm_var_run_t
.EE
- Set files with the container_kvm_var_run_t type, if you want to store the container kvm files under the /run or /var/run directory.
.EX
.PP
.B container_lock_t
.EE
- Set files with the container_lock_t type, if you want to treat the files as container lock data, stored under the /var/lock directory
.EX
.PP
.B container_log_t
.EE
- Set files with the container_log_t type, if you want to treat the data as container log data, usually stored under the /var/log directory.
.br
.TP 5
Paths:
/var/log/lxc(/.*)?, /var/log/lxd(/.*)?, /var/log/pods(/.*)?, /var/log/containers(/.*)?, /var/lib/docker/containers/.*/.*\.log, /var/lib/docker-latest/containers/.*/.*\.log
.EX
.PP
.B container_plugin_var_run_t
.EE
- Set files with the container_plugin_var_run_t type, if you want to store the container plugin files under the /run or /var/run directory.
.EX
.PP
.B container_ro_file_t
.EE
- Set files with the container_ro_file_t type, if you want to treat the files as container ro content.
.br
.TP 5
Paths:
/var/lib/shared(/.*)?, /var/lib/nerdctl(/.*)?, /var/lib/docker/.*/config\.env, /var/lib/docker/init(/.*)?, /var/lib/containerd/[^/]*/sandboxes(/.*)?, /var/lib/docker/overlay(/.*)?, /var/lib/ocid/sandboxes(/.*)?, /var/lib/docker-latest/.*/config\.env, /var/lib/buildkit/runc-.*/executor(/.*?), /var/lib/docker/overlay2(/.*)?, /var/lib/kata-containers(/.*)?, /var/cache/kata-containers(/.*)?, /var/lib/containers/overlay(/.*)?, /var/lib/docker-latest/init(/.*)?, /var/lib/docker/containers/.*/hosts, /var/lib/docker/containers/.*/hostname, /var/lib/containers/overlay2(/.*)?, /var/lib/buildkit/containerd-.*(/.*?), /var/lib/docker-latest/overlay(/.*)?, /var/lib/docker-latest/overlay2(/.*)?, /var/lib/containers/overlay-images(/.*)?, /var/lib/containers/overlay-layers(/.*)?, /var/lib/docker-latest/containers/.*/hosts, /var/lib/docker-latest/containers/.*/hostname, /var/lib/containers/overlay2-images(/.*)?, /var/lib/containers/overlay2-layers(/.*)?, /var/lib/containers/storage/overlay(/.*)?, /var/lib/containers/storage/overlay2(/.*)?, /var/lib/containers/storage/overlay-images(/.*)?, /var/lib/containers/storage/overlay-layers(/.*)?, /var/lib/containers/storage/overlay2-images(/.*)?, /var/lib/containers/storage/overlay2-layers(/.*)?, /home/[^/]+/\.local/share/containers/storage/overlay(/.*)?, /home/[^/]+/\.local/share/containers/storage/overlay2(/.*)?, /home/[^/]+/\.local/share/containers/storage/overlay-images(/.*)?, /home/[^/]+/\.local/share/containers/storage/overlay-layers(/.*)?, /home/[^/]+/\.local/share/containers/storage/overlay2-images(/.*)?, /home/[^/]+/\.local/share/containers/storage/overlay2-layers(/.*)?
.EX
.PP
.B container_runtime_exec_t
.EE
- Set files with the container_runtime_exec_t type, if you want to transition an executable to the container_runtime_t domain.
.br
.TP 5
Paths:
/usr/s?bin/lxc, /usr/s?bin/lxd, /usr/s?bin/crun, /usr/s?bin/runc, /usr/s?bin/crio.*, /usr/s?bin/lxc-.*, /usr/s?bin/lxd-.*, /usr/s?bin/ocid.*, /usr/s?bin/buildah, /usr/s?bin/docker.*, /usr/s?bin/fuidshift, /usr/s?bin/kata-agent, /usr/s?bin/buildkitd.*, /usr/s?bin/containerd.*, /usr/s?bin/buildkit-runc, /usr/s?bin/docker-latest, /usr/s?bin/docker-current, /usr/local/s?bin/crun, /usr/local/s?bin/runc, /usr/local/s?bin/crio.*, /usr/local/s?bin/docker.*, /usr/local/s?bin/kata-agent, /usr/local/s?bin/buildkitd.*, /usr/local/s?bin/containerd.*, /usr/local/s?bin/buildkit-runc, /usr/lib/docker/[^/]*plugin, /usr/libexec/lxc/.*, /usr/libexec/lxd/.*, /usr/bin/container[^/]*plugin, /usr/libexec/docker/.*, /usr/local/lib/docker/[^/]*plugin, /usr/libexec/docker/docker.*, /usr/local/libexec/docker/.*, /usr/local/libexec/docker/docker.*, /usr/bin/podman, /usr/local/bin/podman, /usr/bin/rhel-push-plugin, /usr/sbin/rhel-push-plugin
.EX
.PP
.B container_runtime_tmp_t
.EE
- Set files with the container_runtime_tmp_t type, if you want to store container runtime temporary files in the /tmp directories.
.EX
.PP
.B container_runtime_tmpfs_t
.EE
- Set files with the container_runtime_tmpfs_t type, if you want to store container runtime files on a tmpfs file system.
.EX
.PP
.B container_unit_file_t
.EE
- Set files with the container_unit_file_t type, if you want to treat the files as container unit content.
.br
.TP 5
Paths:
/usr/lib/systemd/system/lxd.*, /usr/lib/systemd/system/docker.*, /usr/lib/systemd/system/buildkit.*, /usr/lib/systemd/system/containerd.*
.EX
.PP
.B container_var_lib_t
.EE
- Set files with the container_var_lib_t type, if you want to store the container files under the /var/lib directory.
.br
.TP 5
Paths:
/exports(/.*)?, /var/lib/cni(/.*)?, /var/lib/lxc(/.*)?, /var/lib/lxd(/.*)?, /var/lib/ocid(/.*)?, /var/lib/docker(/.*)?, /var/lib/kubelet(/.*)?, /var/lib/buildkit(/.*)?, /var/lib/registry(/.*)?, /var/lib/containerd(/.*)?, /var/lib/containers(/.*)?, /var/cache/containers(/.*)?, /var/lib/docker-latest(/.*)?
.EX
.PP
.B container_var_run_t
.EE
- Set files with the container_var_run_t type, if you want to store the container files under the /run or /var/run directory.
.br
.TP 5
Paths:
/run/crio(/.*)?, /run/docker(/.*)?, /run/flannel(/.*)?, /run/buildkit(/.*)?, /run/containerd(/.*)?, /run/containers(/.*)?, /run/docker-client(/.*)?, /run/docker\.pid, /run/docker\.sock
.PP
Note: File context can be temporarily modified with the chcon command. If you want to permanently change the file context you need to use the
.B semanage fcontext
command. This will modify the SELinux labeling database. You will need to use
.B restorecon
to apply the labels.
.SH "COMMANDS"
.B semanage fcontext
can also be used to manipulate default file context mappings.
.PP
.B semanage permissive
can also be used to manipulate whether or not a process type is permissive.
.PP
.B semanage module
can also be used to enable/disable/install/remove policy modules.
.B semanage port
can also be used to manipulate the port definitions
.B semanage boolean
can also be used to manipulate the booleans
.PP
.B system-config-selinux
is a GUI tool available to customize SELinux policy settings.
.SH AUTHOR
This manual page was auto-generated using
.B "sepolicy manpage".
.SH "SEE ALSO"
selinux(8), container(8), semanage(8), restorecon(8), chcon(1), sepolicy(8), setsebool(8), container_auth_selinux(8), container_auth_selinux(8), container_device_selinux(8), container_device_selinux(8), container_device_plugin_selinux(8), container_device_plugin_selinux(8), container_device_plugin_init_selinux(8), container_device_plugin_init_selinux(8), container_engine_selinux(8), container_engine_selinux(8), container_init_selinux(8), container_init_selinux(8), container_kvm_selinux(8), container_kvm_selinux(8), container_logreader_selinux(8), container_logreader_selinux(8), container_logwriter_selinux(8), container_logwriter_selinux(8), container_runtime_selinux(8), container_runtime_selinux(8), container_user_selinux(8), container_user_selinux(8), container_userns_selinux(8), container_userns_selinux(8)