Use it when an operation is denied although file permissions allow it, or to confine services.
SELinux · Security
SELinux is mandatory access control on RHEL-family systems: every process and file has a security context, and the policy decides which domains may access which types, regardless of Unix permissions.
1. getenforce — Enforcing?
2. ausearch -m AVC -ts recent — denial with scontext, tcontext, tclass?
3. Wrong label → restorecon -Rv <path> (or semanage fcontext -a + restorecon).
4. Boolean → getsebool -a | grep <service>; setsebool -P <bool> on.
5. Non-standard port → semanage port -a -t <type> -p tcp <port>.
process domain and file type → policy rule checked → allowed or AVC denial logged
For Security → SELinux, continue with the first unproven Topic check: Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for SELinux. If that boundary is healthy, advance to the adjacent check: Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
process domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcome
Healthy evidence: SELinux is enabled in the intended mode, relevant subjects/objects have expected contexts and correlated AVC behavior agrees with the workload result
Step 2 Verification and output interpretation Verify boundary
For SELinux/AppArmor, correlate denial records with current mode/profile/labels and confirm the access vector/path actually matches the failing operation.
Verification chain. process domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcome
Step 3 Specialized verification Verify boundary
Confirm mode/policy state and the source/target contexts involved in the failing operation. Correlate AVC denials from audit/journal with the exact timestamp and process, then determine whether the denial reflects wrong labeling, a missing boolean, expected confinement or a genuine policy gap. Use restorecon checks to compare current labels with policy defaults. After remediation, repeat the original operation in enforcing mode and ensure the expected denial is gone without broad new denials.
Step 4 Verification path Verify boundary
Exercise one safe negative or boundary case implied by UID/GID mismatch, stale group membership, ACL/mode conflict, missing capability, noexec/readonly mount, SELinux denial, AppArmor denial, expired/untrusted certificate or secret exposure.
Step 5 Failure modes and next checks Narrow the fault
Suspicious evidence: permissive mode, mislabeled objects, broad local policy, temporary label fixes or unrelated AVC noise obscures the real first failing step
Step 6 Common mistakes Narrow the fault
- Turning SELinux off on servers.
Step 7 Special cases and limits Narrow the fault
SELinux does not replace Unix DAC; both must permit an operation. Permissive mode logs would-be denials but does not enforce them, so success in permissive does not show correct policy. “No AVC” does not automatically clear SELinux if auditing is incomplete or the failure occurs elsewhere. chcon success does not make a label persistent. Keep DAC, SELinux label/policy, application authorization and resource availability separate.
Step 8 Where it fails Narrow the fault
Walk identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation and stop where observed state diverges.
Common failure classes are UID/GID mismatch, stale group membership, ACL/mode conflict, missing capability, noexec/readonly mount, SELinux denial, AppArmor denial, expired/untrusted certificate or secret exposure. Also consider stale generated config, wrong environment, wrong namespace/chroot/container, package/provider mismatch, dependency ordering, immutable/read-only mounts, exhausted inode/block resources, capabilities, SELinux/AppArmor denial, systemd sandboxing, cgroup limits and boot-time state that differs from the interactive shell.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Never disable SELinux to fix a problem: read the AVC denial and fix the label (restorecon, semanage fcontext), boolean (setsebool -P) or port (semanage port). Use permissive mode only briefly to confirm.
sealert -a /var/log/audit/audit.log— explained denials (setroubleshoot)sestatus / aa-status— SELinux or AppArmor statess -tulpn— listening servicesjournalctl -u sshd -g 'Failed'— failed loginsausearch -m avc,user_login -ts today— audit events (auditd)
ReferenceWhat it is1 section · depth on demand
Overview
SELinux labels every process and object with a context (user:role:type:level) and enforces type-enforcement rules: a process type (domain, e.g. httpd_t) may only access object types allowed by policy (e.g. httpd_sys_content_t).
getenforce; sestatus
ps -eZ | grep httpd
ls -Z /var/www/html
semanage fcontext -a -t httpd_sys_content_t '/srv/www(/.*)?'; restorecon -Rv /srv/www
setsebool -P httpd_can_network_connect on
ausearch -m AVC -ts recent | audit2why
Fix denials with correct labels, booleans or port definitions (semanage port -a -t http_port_t -p tcp 8081) — not by disabling SELinux.
ReferenceWhy it matters1 section · depth on demand
Quality lift: concrete internals
Permission denial can arise from path traversal, ACL, capabilities or SELinux/AppArmor independently.
ReferenceImportant terms & boundaries6 sections · depth on demand
What this shows and what it does not
This Security subtopic establishes SELinux’s role in the layered decision; use the dedicated SELinux branch to show modes, contexts, labels and remediation.
Security → SELinux is the architecture-level bridge to the dedicated SELinux root.
Permission denial can arise from path traversal, ACL, capabilities or SELinux/AppArmor independently.
In depth
SELinux in a security programme
From a security point of view, SELinux's value is containment. A compromised service can only do what its type is allowed to do, whatever user it runs as. The selinux(8) manual page describes the main elements:
- The targeted policy, the usual default, confines selected services and leaves most user processes unconfined.
- The MLS policy confines everything, and adds multi-level security checks.
- Policy booleans adjust behaviour at runtime.
- The modes are set in
/etc/selinux/config. The manual notes thatSELINUX=disabledis deprecated, and recommends theselinux=0boot option if it really must be turned off.
What SELinux contains
| Scenario | Without SELinux | With SELinux (targeted) |
|---|---|---|
Web application RCE as apache | Reads anything apache can read, e.g. home directories | Limited to httpd_t permissions; home directories denied |
| A compromised database | Can connect to anything | Network access only as the policy allows |
| A service writing in an odd directory | Allowed if permissions allow | Denied unless that path has the right type |
Review checklist
| Check | Command |
|---|---|
| Mode and policy | sestatus |
| Domains made permissive individually | semanage permissive -l |
| Booleans changed from the defaults | semanage boolean -l -C |
| Local file context changes | semanage fcontext -l -C |
| Local port changes | semanage port -l -C |
| Recent denials | ausearch -m AVC -ts recent |
| Unconfined services | ps -eZ | grep unconfined_service_t |
Local customisations are where weaknesses usually hide. A permissive domain, or a boolean like httpd_execmem turned on to "make something work", removes protection quietly.
host$ sestatus | grep -E "SELinux status|Current mode|Loaded policy"
SELinux status: enabled
Loaded policy name: targeted
Current mode: enforcing
host$ sudo semanage permissive -l
Customized Permissive Types
httpd_t
host$ sudo semanage boolean -l -C
SELinux boolean State Default Description
httpd_can_network_connect (on , off) Allow httpd to can network connect
host$ ps -eZ | grep -c unconfined_service_t
3
host$ sudo semanage permissive -d httpd_t
Reading the example
The system reports "enforcing", but httpd_t, the web server domain, was made permissive. Its denials are only logged, not enforced, which removes SELinux protection for the most exposed service. The boolean change may be legitimate, for example for a reverse proxy, but it should be documented.
Documented example, not captured output.
How it works at runtime
SELinux is part of Security → SELinux. Security → SELinux explains SELinux as one component of Linux security, emphasizing mode, loaded policy, subject/object contexts and AVC decisions without replacing the dedicated SELinux operational branch.
Runtime state ownership and mechanics. Linux security composes authentication (PAM and service mechanisms), identity/credentials, DAC permissions/ACLs, capabilities, LSM policy such as SELinux/AppArmor, audit and service/network policy. SELinux labels/types and AppArmor path/profile rules differ in policy model, while auditd records selected security-relevant events rather than making authorization decisions.
Topic-specific state model. Security → SELinux explains SELinux as one component of Linux security, emphasizing mode, loaded policy, subject/object contexts and AVC decisions without replacing the dedicated SELinux operational branch.
Technical metadata. Linux distribution/kernel + boot/time + user/group/process/service identity + PAM/SSH/DAC/ACL + SELinux/AppArmor mode/context/profile + audit/log correlation + key/certificate/SAN/EKU/chain/trust store/SNI + original workload result.
Interpretation rule. - SELinux enabled ≠ enforcing with the expected policy loaded.
- A DAC allow ≠ SELinux allow, and an SELinux allow ≠ the rest of the access path permits the operation.
Specialized mechanics
SELinux is a label-based mandatory access control system enforced by the kernel LSM framework. Policy evaluates source security context, target context, object class and requested permission; DAC permission is evaluated separately. Enforcing, permissive and disabled are materially different states. Type enforcement is the dominant policy mechanism, while roles/users/categories add other dimensions depending on policy. File labels usually come from persistent file-context policy plus the current xattr on the object.
Mechanics
Follow the path in order: identity/group resolution → Unix mode/ACL/capability → mount/sandbox constraint → SELinux/AppArmor policy → credential/TLS trust → protected operation.
Important negative cases include UID/GID mismatch, stale group membership, ACL/mode conflict, missing capability, noexec/readonly mount, SELinux denial, AppArmor denial, expired/untrusted certificate or secret exposure.
Limits and how it fails
Primary failure point. This Security subtopic establishes SELinux’s role in the layered decision; use the dedicated SELinux branch to show modes, contexts, labels and remediation.
Disabling SELinux/AppArmor to make an error disappear only localizes a policy boundary and can hide the real label/profile defect.
ReferenceConfiguration & state3 sections · depth on demand
Configuration, persistence and lifecycle
PAM stack order/control flags matter; sudo/SSH hardening can lock out administration; SELinux policy should normally be fixed through correct labels/booleans/policy rather than permanent disablement; AppArmor profiles should move from complain to enforce only after reviewing legitimate workload behavior.
Distribution/platform context. Security → SELinux is the architecture-level bridge to the dedicated SELinux root.
Specialized lifecycle
Prefer changing labels, booleans or policy in the narrow scope that matches the application design instead of disabling enforcement. Persistent file-label mappings should be defined through semanage fcontext and then applied with restorecon; a one-off chcon can be overwritten by relabeling. Booleans change predefined policy branches and should be documented when made persistent. Custom modules should be generated only after the denial is understood; blindly turning audit denials into allow rules can authorize unintended behavior.
Lifecycle
systemd generators and drop-ins, package scripts, udev, mount helpers, netlink, resolver caches, namespaces, SELinux/AppArmor policy and kernel drivers can make runtime state differ from the file or command that appears to own it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Security → SELinux. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/security/index.html · confidence 94%Authoritative Linux project/vendor documentation reviewed for bounded reference claims: SELinux modes, policy decisions, labels and denial-analysis boundaries. Documentation-based technical verification only; not lab or production-runtime proof. The schema vendor_doc method is used for authoritative project/vendor documentation; deployment applicability remains separate evidence.
Basis: https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/using_selinux/ · confidence 93%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
SELinux operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for SELinux.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | Security → SELinux explains SELinux as one component of Linux security, emphasizing mode, loaded policy, subject/object contexts and AVC decisions without replacing the dedicated SELinux operational branch. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin host + boot/time + real identity/workload → identify authoritative policy/key/trust source → read back loaded/effective runtime state → reproduce one safe allow/deny/handshake test → correlate audit/service/kernel evidence → locate first failed boundary → make the smallest persistent change → repeat original workload + regression/recovery check. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | process domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcome | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | This Security subtopic establishes SELinux’s role in the layered decision; use the dedicated SELinux branch to prove modes, contexts, labels and remediation. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux security/trust evidence can establish this proof path: process domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcome | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove unobserved identities, objects, policies, namespaces, endpoints or time periods. This Security subtopic establishes SELinux’s role in the layered decision; use the dedicated SELinux branch to prove modes, contexts, labels and remediation. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven security/trust boundary, capture the adjacent effective state and audit/handshake evidence, make only the demonstrated persistent change, then repeat the original workload plus recovery/regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
SELinux · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | SELinux |
|---|---|
| Topic path | Security → SELinux |
| Runtime state | Security → SELinux explains SELinux as one component of Linux security, emphasizing mode, loaded policy, subject/object contexts and AVC decisions without replacing the dedicated SELinux operational branch. |
| Fast checks | - Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for SELinux. - Read back the effective runtime state and precedence rather than assuming an edited file, package state or service status is active. - Reproduce one safe allowed/denied or handshake/access test and correlate kernel/service/audit evidence at the first relevant boundary. - Apply the smallest persistent cause-specific change, then repeat the original test plus an adjacent regression/recovery check. |
| Verification chain | process domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcome Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | This Security subtopic establishes SELinux’s role in the layered decision; use the dedicated SELinux branch to prove modes, contexts, labels and remediation. Boundary chain: process credentials/namespace → path/mount lookup → DAC/ACL/LSM → filesystem metadata → block/device/backend → completion/read-back. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |
SELinux · specialized operational reference
Topic-specific Linux mechanics, lifecycle, proof path and failure-boundary lookup.
| Operational boundary | Topic-specific reference |
|---|---|
| Decision | source context + target context + class + permission |
| Persistent label | semanage fcontext → restorecon |
| Modes | enforcing / permissive / disabled |
| Proof | Original operation succeeds in enforcing with scoped policy |
Deep reference
Healthy vs suspicious evidence
Commands
getenforce
ausearch -m AVC -ts today