Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

SELinux · Security

Direct answer

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.

When to use this

Use it when an operation is denied although file permissions allow it, or to confine services.

First 30 seconds

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>.

Operational verification

process domain and file type → policy rule checked → allowed or AVC denial logged

Evidence · next step

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
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it when an operation is denied although file permissions allow it, or to confine services.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

8 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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 references

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.

observation · 1
Key points

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.

Key checks
  • sealert -a /var/log/audit/audit.log — explained denials (setroubleshoot)
  • sestatus / aa-status — SELinux or AppArmor state
  • ss -tulpn — listening services
  • journalctl -u sshd -g 'Failed' — failed logins
  • ausearch -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 that SELINUX=disabled is deprecated, and recommends the selinux=0 boot option if it really must be turned off.

What SELinux contains

ScenarioWithout SELinuxWith SELinux (targeted)
Web application RCE as apacheReads anything apache can read, e.g. home directoriesLimited to httpd_t permissions; home directories denied
A compromised databaseCan connect to anythingNetwork access only as the policy allows
A service writing in an odd directoryAllowed if permissions allowDenied unless that path has the right type

Review checklist

CheckCommand
Mode and policysestatus
Domains made permissive individuallysemanage permissive -l
Booleans changed from the defaultssemanage boolean -l -C
Local file context changessemanage fcontext -l -C
Local port changessemanage port -l -C
Recent denialsausearch -m AVC -ts recent
Unconfined servicesps -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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

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
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

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%
2026-09-13 · vendor docSELinux on RHEL 9 RHEL 9

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%
Technical changelog & impact

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.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

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.

Aliases that resolve here
selinux security layerselinux linux securitymandatory access control linux
Embedded reference data

Quick lookup tables

SELinux operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for SELinux.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateSecurity → 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 verificationPin 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 chainprocess domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcomeTrace requested/configured state through effective state to the observed workload result.
Failure boundaryThis 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 evidenceCorrelated Linux security/trust evidence can establish this proof path: process domain + object context → DAC/capability checks → SELinux policy decision → allow/deny/audit → application outcomeUse this observation only for the specific claim it actually supports.
Evidence limitIt 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 checkContinue 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 boundarySELinux
Topic pathSecurity → SELinux
Runtime stateSecurity → 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 chainprocess 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 boundaryThis 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 ruleProve 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 boundaryTopic-specific reference
Decisionsource context + target context + class + permission
Persistent labelsemanage fcontext → restorecon
Modesenforcing / permissive / disabled
ProofOriginal operation succeeds in enforcing with scoped policy
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Commands

getenforce
ausearch -m AVC -ts today
Confirmation

Confirm action

Continue?