Sub topic 5
The Targeted Policy and What Else Exists
Assume you are comfortable with Linux permissions, systemctl, journalctl, and basic web-server administration. This chapter focuses on how SELinux policy choices affect service confinement. It does not replace the practical work of labeling files, ports, or booleans.
What a policy type controls
An SELinux policy is the loaded set of rules that controls which security domains may access which types. The policy type is a broad policy design, not the same thing as a file or process type.
Most RHEL-family systems use the targeted policy. Targeted policy confines selected network-facing services, such as Apache, PostgreSQL, and SSH. These services run in confined domains such as httpd_t or sshd_t.
Processes without a specific confinement policy usually run in an unconfined domain, often unconfined_t. Normal Linux ownership and permission bits still apply to these processes, but SELinux adds few restrictions to their behavior.
This design gives useful protection without requiring every program on the system to have a complete SELinux policy.
sestatus
grep '^SELINUXTYPE=' /etc/selinux/config
ps -eZ | headThe sestatus output shows the current mode and the loaded policy name. The configuration file records the policy selected for the next boot. The -Z option displays SELinux contexts, including process domains.
| Policy choice | Main purpose | Typical use |
|---|---|---|
| targeted | Confine selected services while leaving other programs mostly unconfined | General-purpose servers |
| MLS | Enforce labeled security levels and categories | High-assurance or specialized environments |
| mls with MCS features | Add category-based separation within supported policies | Container and workload separation |
Targeted policy versus MLS
MLS, or Multi-Level Security, assigns security levels such as 低 and 高 to subjects and objects. A policy can then enforce rules such as “a process at one level cannot read data at a higher level.” MLS can also use categories to separate information within the same level.
MLS is designed for environments with formal information classification requirements. It requires careful labeling, user mapping, and operational discipline. Turning it on does not automatically make an ordinary server compliant or secure. Every application and data flow still needs an appropriate policy.
Targeted policy can use MCS, or Multi-Category Security, features without being a full MLS deployment. For example, container tooling can assign categories such as c123,c456 to container processes and files. The categories help prevent one container from accessing another container's labeled content. MCS categories provide separation, but they do not create the complete read-up and write-down model of MLS.
Choosing and changing a policy
Use targeted policy unless your organization has a specific requirement for MLS. Changing the policy type is a system-wide decision. It can expose unlabeled files, prevent services from starting, and require relabeling and testing. Treat it as a planned migration, not as a troubleshooting command.
The policy type and the SELinux mode are separate settings:
- The policy type determines which rules are loaded.
- The mode determines whether those rules are enforced, only logged, or inactive.
A targeted policy in permissive mode still has targeted rules, but it does not block access. A targeted policy in enforcing mode applies those rules.
Exercise
A server runs targeted policy in enforcing mode, but a custom Apache document root is denied. Should you switch to MLS?
Show answer
No. Keep targeted policy and correct the document root's SELinux file type, then verify the denial and service behavior.