Security-Enhanced Linux (SELinux) is a security module of the Linux kernel. It provides the mandatory access control (MAC) mechanism to protect sensitive or important files based on customized requirements in the Linux system.
SELinux adopts user-defined rules to restrict users' access permissions during program running. This mechanism is independent of other secure access control mechanisms of the Linux kernel and is a powerful supplement to the discretionary access control (DAC) mechanism.
Traditional UNIX permission access control is based on the DAC mechanism, which can determine permissions based on the runtime identity. Generally, the file system restricts permissions based on the r (read), w (write), and x (delete) of the owner, group, and other permission groups. Due to lack of detailed permission classification, permissions cannot be restricted for different processes. If all programs are authorized to access a file, malicious programs may have the same access permission, which poses security risks. Compared with the DAC mechanism, the MAC mechanism provided by SELinux offers additional control over the permissions on specific items, covering the file system, files, directories, processes, file descriptors, ports, messages, and network interfaces.
DAC is an access control mode in which an access permission is determined based on runtime identity.
The MAC mechanism completely controls access and can control access permissions on specific items based on the DAC mechanism.
SELinux performs the MAC security mechanism based on the domain-type model. A process is defined as a subject, resources (such as files and directories) to be accessed are defined as objects, and a series of permission access rules for the subject domain accessing the object types are defined based on the security context. In this way, access control is implemented. With SELinux used, even if a restricted process is compromised by an attacker, the attacker can access resources only within the specified permission range, limiting the damage scope.
The SELinux mechanism involves the following parts:
As shown in Figure 1, if a subject (process) wants to access a target object (resource file), the subject (process) sends a request to the SELinux component of the Linux kernel. After receiving the request, the SELinux component must analyze the policy rule and compare the security contexts of the subject domain and object type. If the security context complies with the allow rule in the SELinux policy database, the process is allowed to access the target resource. SELinux supports permissive and enforcing modes. In permissive mode, if access operations are not allowed by a policy, the system does not reject them but can record these operations. In enforcing mode, the system rejects the operations that are not allowed by a policy. Currently, the VRPv8 system uses the enforcing mode.
SELinux uses user-defined rules to restrict users' access permissions during program running, reducing the impact and loss caused by attacks.