24.2 Configuring and Using SELinux

Traditional Linux security is based on a Discretionary Access Control (DAC) policy, which provides minimal protection from broken software or from malware that is running as a normal user or as root. Access to files and devices is based solely on user identity and ownership. Malware or broken software can do anything with files and resources that the user that started the process can do. If the user is root or the application is setuid or setgid to root, the process can have root-access control over the entire file system.

The National Security Agency created Security Enhanced Linux (SELinux) to provide a finer-grained level of control over files, processes, users and applications in the Linux operating system. The SELinux enhancement to the Linux kernel implements the Mandatory Access Control (MAC) policy, which allows you to define a security policy that provides granular permissions for all users, programs, processes, files, and devices. The kernel's access control decisions are based on all the security relevant information available, and not solely on the authenticated user identity.

When security-relevant access occurs, such as when a process attempts to open a file, SELinux intercepts the operation in the kernel. If a MAC policy rule allows the operation, it continues; otherwise, SELinux blocks the operation and returns an error to the process. The kernel checks and enforces DAC policy rules before MAC rules, so it does not check SELinux policy rules if DAC rules have already denied access to a resource.

The following table describes the SELinux packages that are installed by default with Oracle Linux:




Provides utilities such as load_policy, restorecon, secon, setfiles, semodule, sestatus, and setsebool for operating and managing SELinux.


Provides the API that SELinux applications use to get and set process and file security contexts, and to obtain security policy decisions.


Provides the SELinux Reference Policy, which is used as the basis for other policies, such as the SELinux targeted policy.


Provides support for the SELinux targeted policy, where objects outside the targeted domains run under DAC.


Contains Python bindings for developing SELinux applications.


Provides the avcstat, getenforce, getsebool, matchpathcon, selinuxconlist, selinuxdefcon, selinuxenabled, setenforce, and togglesebool utilities.

The following table describes a selection of useful SELinux packages that are not installed by default:




Translates SELinux levels, such as s0-s0:c0.c1023, to an easier-to-read form, such as SystemLow-SystemHigh.


Provides a GUI (system-config-selinux) that you can use to manage SELinux. For example, you can use the GUI to set the system default enforcing mode and policy type.


Provides additional Python utilities for operating SELinux, such as audit2allow, audit2why, chcat, and semanage.


Provides support for the strict Multilevel Security (MLS) policy as an alternative to the SELinux targeted policy.


Provides the GUI that allows you to view setroubleshoot-server messages using the sealert command.


Translates access-denial messages from SELinux into detailed descriptions that you can view on the command line using the sealert command.


Provides the Tresys Technology SETools distribution of tools and libraries, which you can use to analyze and query policies, monitor and report audit logs, and manage file context.

Use yum or another suitable package manager to install the SELinux packages that you require on your system.

For more information about SELinux, refer to the SELinux Project Wiki, the selinux(8) manual page, and the manual pages for the SELinux commands.