container_selinux - Man Page
Security Enhanced Linux Policy for the container processes
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 ps command with the -Z qualifier.
For example:
ps -eZ | grep container_t
Process Types
SELinux defines process types (domains) for each process running on the system
You can see the context of a process using the -Z option to psbP
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.
The following process types are defined for container:
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
Note: 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.
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
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.
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.
setsebool -P deny_ptrace 1
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.
setsebool -P virt_sandbox_use_all_caps 1
If you want to allow sandbox containers to send audit messages, you must turn on the virt_sandbox_use_audit boolean. Enabled by default.
setsebool -P virt_sandbox_use_audit 1
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.
setsebool -P virt_sandbox_use_netlink 1
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.
setsebool -P virt_sandbox_use_sys_admin 1
Port Types
SELinux defines port types to represent TCP and UDP ports.
You can see the types associated with a port by using the following command:
semanage port -l
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.
The following port types are defined for container:
container_port_t
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.
bpf_t
/sys/fs/bpf
cifs_t
container_file_t
/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/[^/]*/.*
ecryptfs_t
/home/[^/]+/.Private(/.*)?
/home/[^/]+/.ecryptfs(/.*)?
fs_t
fusefs_t
/run/user/[0-9]+/gvfs
hugetlbfs_t
/dev/hugepages
/usr/lib/udev/devices/hugepages
nfs_t
onload_fs_t
svirt_home_t
/home/[^/]+/.libvirt/qemu(/.*)?
/home/[^/]+/.cache/libvirt/qemu(/.*)?
/home/[^/]+/.config/libvirt/qemu(/.*)?
/home/[^/]+/.local/share/libvirt/boot(/.*)?
/home/[^/]+/.local/share/libvirt/images(/.*)?
/home/[^/]+/.local/share/gnome-boxes/images(/.*)?
File Contexts
SELinux requires files to have an extended attribute to define the file type.
You can see the context of a file using the -Z option to lsbP
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.
EQUIVALENCE DIRECTORIES
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:
semanage fcontext -a -e /var/lib/buildkit /srv/buildkit
restorecon -R -v /srv/buildkit
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:
semanage fcontext -a -e /var/lib/containerd /srv/containerd
restorecon -R -v /srv/containerd
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:
semanage fcontext -a -e /var/lib/containers /srv/containers
restorecon -R -v /srv/containers
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:
semanage fcontext -a -e /var/lib/docker /srv/docker
restorecon -R -v /srv/docker
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:
semanage fcontext -a -e /var/lib/kubelet /srv/kubelet
restorecon -R -v /srv/kubelet
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:
semanage fcontext -a -e /var/lib/nerdctl /srv/nerdctl
restorecon -R -v /srv/nerdctl
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:
semanage fcontext -a -e /var/lib/ocid /srv/ocid
restorecon -R -v /srv/ocid
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.
semanage fcontext -a -t container_var_lib_t '/srv/container/content(/.*)?'
restorecon -R -v /srv/mycontainer_content
Note: SELinux often uses regular expressions to specify labels that match multiple files.
The following file types are defined for container:
container_auth_exec_t
- Set files with the container_auth_exec_t type, if you want to transition an executable to the container_auth_t domain.
- Paths:
/usr/s?bin/docker-novolume-plugin, /usr/lib/docker/docker-novolume-plugin
container_config_t
- 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.
- Paths:
/etc/crio(/.*)?, /etc/docker(/.*)?, /etc/buildkit(/.*)?, /etc/containerd(/.*)?, /etc/docker-latest(/.*)?
container_file_t
- Set files with the container_file_t type, if you want to treat the files as container content.
- 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/[^/]*/.*
container_home_t
- Set files with the container_home_t type, if you want to store container files in the users home directory.
container_kvm_var_run_t
- 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.
container_lock_t
- 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
container_log_t
- 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.
- Paths:
/var/log/lxc(/.*)?, /var/log/lxd(/.*)?, /var/log/pods(/.*)?, /var/log/containers(/.*)?, /var/lib/docker/containers/.*/.*.log, /var/lib/docker-latest/containers/.*/.*.log
container_plugin_var_run_t
- 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.
container_ro_file_t
- Set files with the container_ro_file_t type, if you want to treat the files as container ro content.
- 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(/.*)?
container_runtime_exec_t
- Set files with the container_runtime_exec_t type, if you want to transition an executable to the container_runtime_t domain.
- 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
container_runtime_tmp_t
- Set files with the container_runtime_tmp_t type, if you want to store container runtime temporary files in the /tmp directories.
container_runtime_tmpfs_t
- Set files with the container_runtime_tmpfs_t type, if you want to store container runtime files on a tmpfs file system.
container_unit_file_t
- Set files with the container_unit_file_t type, if you want to treat the files as container unit content.
- Paths:
/usr/lib/systemd/system/lxd.*, /usr/lib/systemd/system/docker.*, /usr/lib/systemd/system/buildkit.*, /usr/lib/systemd/system/containerd.*
container_var_lib_t
- Set files with the container_var_lib_t type, if you want to store the container files under the /var/lib directory.
- 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(/.*)?
container_var_run_t
- Set files with the container_var_run_t type, if you want to store the container files under the /run or /var/run directory.
- Paths:
/run/crio(/.*)?, /run/docker(/.*)?, /run/flannel(/.*)?, /run/buildkit(/.*)?, /run/containerd(/.*)?, /run/containers(/.*)?, /run/docker-client(/.*)?, /run/docker.pid, /run/docker.sock
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 semanage fcontext command. This will modify the SELinux labeling database. You will need to use restorecon to apply the labels.
Commands
semanage fcontext can also be used to manipulate default file context mappings.
semanage permissive can also be used to manipulate whether or not a process type is permissive.
semanage module can also be used to enable/disable/install/remove policy modules.
semanage port can also be used to manipulate the port definitions
semanage boolean can also be used to manipulate the booleans
system-config-selinux is a GUI tool available to customize SELinux policy settings.
Author
This manual page was auto-generated using sepolicy manpage .
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)