Use it when a service fails only with SELinux enforcing.
SELinux Troubleshooting
SELinux troubleshooting reads AVC denials and applies the smallest fix: correct the label, enable a boolean, label a port, or as a last resort create a local policy module.
1. ausearch -m AVC -ts recent — denials?
2. audit2why -a / sealert -a /var/log/audit/audit.log — suggested fix.
3. Label → restorecon/semanage; boolean → setsebool -P; port → semanage port.
4. No denial but still blocked → semodule -DB to show dontaudit, then semodule -B.
5. Last resort: audit2allow -M local_fix reviewed, semodule -i.
operation denied → AVC logged → cause classified (label, boolean, port, policy) → smallest fix → enforcing works
For SELinux → SELinux Troubleshooting, 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 Troubleshooting. 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
symptom/time → reproduce under known mode → correlate AVC/audit event → inspect subject/object context + policy/boolean → minimal persistent remediation → enforcing retest → regression
Healthy evidence: AVCs correlate with the exact failing syscall/path, contexts/policy are explained, the minimal fix persists and enforcing-mode acceptance tests pass
Step 2 Close the fix in enforcing mode Verify boundary
After the smallest correction, return to enforcing mode and clear or timestamp the audit window so the retest is unambiguous. Repeat the original operation from the same service domain and verify that no new denial appears for that path. Confirm labels survive restorecon and reboot expectations, and that any boolean or custom policy is persistent by design. Then perform the consumer-visible test, not only a service restart. A service that starts successfully can still encounter later denials on data, log, socket or network access. The limit of what it shows is an enforcing-mode original test with expected policy state and no new relevant AVCs, while unrelated audit noise remains separate.
Step 3 Verification and output interpretation Verify boundary
Verification chain. symptom/time → reproduce under known mode → correlate AVC/audit event → inspect subject/object context + policy/boolean → minimal persistent remediation → enforcing retest → regression
Step 4 Commands Verify boundary
ausearch -m AVC -ts recent
sealert -a /var/log/audit/audit.log
getsebool -a | grep httpd
Step 5 Treat AVC records as a structured policy decision Narrow the fault
SELinux troubleshooting starts with the exact denied operation, not with changing enforcement mode. An AVC record identifies the source context, target context, object class and denied permission that participated in the policy decision. Determine whether the labels are correct for the file, process, port or resource and whether the action is expected by the application’s supported policy. Mislabeling is common after copying data to nonstandard paths; a custom path may need the correct persistent file-context mapping followed by relabeling rather than a broad allow rule. Boolean settings can intentionally permit optional behavior, but they should be selected because they match the documented access pattern, not because an audit2allow result happened to compile.
Step 6 Separate labeling, policy and application failures Narrow the fault
Use a simple branch sequence. If no relevant AVC exists during the reproduced failure, SELinux has not yet been confirmed as the blocking boundary. If an AVC exists, compare the target label with the expected type and check whether the source domain should legitimately access that class and permission. Correct an incorrect label with persistent context configuration; enable a narrowly appropriate boolean when the workload matches its intended policy; create custom policy only when the access is both necessary and not represented by existing policy. Permissive mode can be a short diagnostic comparison, but success in permissive mode shows only that SELinux enforcement contributed to the failure, not that the generated allow rule is safe or minimal.
Step 7 Failure modes and next checks Narrow the fault
Suspicious evidence: irrelevant AVC noise drives changes, audit time/window is wrong, policy is generated broadly from logs, permissive/disabled mode masks the issue or the true failure is outside SELinux
Step 8 Common mistakes Narrow the fault
- Using
audit2allowblindly to create broad policies.
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.
Use sealert or audit2why to explain denials. Only use audit2allow to build a module after confirming no label or boolean fixes it — review the generated rules. dontaudit rules can hide denials (semodule -DB temporarily).
audit2why -a— explain denialsgetenforce / sestatus— mode and policyls -Z <path>— file contextps -eZ | grep <proc>— process contextausearch -m AVC -ts recent— recent denialssemanage fcontext -l | grep <path>— context rules for a path
ReferenceImportant terms & boundaries5 sections · depth on demand
What this shows and what it does not
Troubleshooting is resolved only when the first SELinux boundary is confirmed, corrected minimally/persistently and the original workload succeeds in enforcing mode without unrelated policy broadening.
In depth
From denial to correct fix
# ausearch -m AVC,USER_AVC -ts recent
type=AVC msg=audit(1764238891.412:921): avc: denied { read } for pid=2211 comm="httpd" name="index.html" dev="dm-0" ino=393251 scontext=system_u:system_r:httpd_t:s0 tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=0
# sealert -a /var/log/audit/audit.log | less
# ls -Z /srv/www/index.html
unconfined_u:object_r:user_home_t:s0 /srv/www/index.html
Red Hat's SELinux troubleshooting chapter uses ausearch -m AVC to find denials, sealert for explanations and suggested fixes, semanage fcontext with restorecon to apply correct labels, and semodule -DB to temporarily disable dontaudit rules so hidden denials appear (semodule -B re-enables them).
Choose the fix by cause
| Cause | Fix | Example |
|---|---|---|
Wrong label (file moved from home, copied with mv) | Label correctly | semanage fcontext -a -t httpd_sys_content_t '/srv/www(/.*)?' then restorecon -Rv /srv/www |
| Feature needs a boolean | Turn on the boolean | setsebool -P httpd_can_network_connect on |
| Service on a non-standard port | Add the port type | semanage port -a -t http_port_t -p tcp 8443 |
| Genuinely missing policy | Local module, reviewed | audit2allow -M myhttpd < avc.log — read the .te before loading |
Using audit2allow for a labelling problem produces an over-broad policy; fix labels and booleans first.
Reading the AVC
| Field | Meaning |
|---|---|
scontext | Process domain (httpd_t) |
tcontext | Target type (user_home_t) — wrong for web content |
tclass | Object class (file, dir, tcp_socket) |
permissive=0 | Enforcing — actually blocked |
Finish in enforcing mode
setenforce 0 is a diagnostic switch for minutes, not a fix. After the change: setenforce 1, repeat the action, and confirm no new AVC with ausearch -m AVC -ts recent. getenforce and sestatus show the current mode; per-domain permissive (semanage permissive -a httpd_t) limits risk during investigation.
*The AVC audit entry uses example security contexts to illustrate an SELinux denial, not an actual audited access attempt.*
How it works at runtime
SELinux Troubleshooting is part of SELinux → SELinux Troubleshooting. SELinux Troubleshooting isolates whether an observed failure is caused by mode, context, label mapping, boolean, transition or policy by correlating AVC records with the exact denied operation before changing policy.
Topic-specific state model. SELinux Troubleshooting isolates whether an observed failure is caused by mode, context, label mapping, boolean, transition or policy by correlating AVC records with the exact denied operation before changing policy.
Interpretation rule. - An AVC appears near the failure ≠ it caused the user-visible symptom.
- Disabling SELinux and seeing success ≠ disabling it is an acceptable fix or the policy issue is understood.
Method
SELinux troubleshooting workflow:
1. Confirm SELinux is the cause: ausearch -m AVC -ts recent shows denials at the time of the failure (or test with setenforce 0 briefly).
2. Explain: ausearch -m AVC -ts recent | audit2why — label, boolean or missing rule?
3. Fix in order of preference: correct label (restorecon/semanage fcontext), boolean (setsebool -P), port type (semanage port), and only then a local policy module.
4. Local module as last resort:
ausearch -m AVC -c myapp --raw | audit2allow -M myapp_local
semodule -i myapp_local.pp
Review generated rules — blanket allow rules can open more than needed.
Limits and how it fails
Primary failure point. Troubleshooting is resolved only when the first SELinux boundary is confirmed, corrected minimally/persistently and the original workload succeeds in enforcing mode without unrelated policy broadening.
ReferenceConfiguration & state1 section · depth on demand
Configuration, persistence and lifecycle
Distribution/platform context. SELinux Troubleshooting owns symptom-to-policy isolation; hand off to DAC, service, filesystem, networking or application branches when SELinux is not the first failure.
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 SELinux → SELinux Troubleshooting. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://selinuxproject.org/page/Main_Page · confidence 94%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 Troubleshooting operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for SELinux Troubleshooting.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | SELinux Troubleshooting isolates whether an observed failure is caused by mode, context, label mapping, boolean, transition or policy by correlating AVC records with the exact denied operation before changing policy. | 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 | symptom/time → reproduce under known mode → correlate AVC/audit event → inspect subject/object context + policy/boolean → minimal persistent remediation → enforcing retest → regression | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | Troubleshooting closes only when the first SELinux boundary is proven, corrected minimally/persistently and the original workload succeeds in enforcing mode without unrelated policy broadening. | 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: symptom/time → reproduce under known mode → correlate AVC/audit event → inspect subject/object context + policy/boolean → minimal persistent remediation → enforcing retest → regression | 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. Troubleshooting closes only when the first SELinux boundary is proven, corrected minimally/persistently and the original workload succeeds in enforcing mode without unrelated policy broadening. | 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 Troubleshooting · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | SELinux Troubleshooting |
|---|---|
| Topic path | SELinux → SELinux Troubleshooting |
| Runtime state | SELinux Troubleshooting isolates whether an observed failure is caused by mode, context, label mapping, boolean, transition or policy by correlating AVC records with the exact denied operation before changing policy. |
| Fast checks | - Record exact host, distribution/kernel, boot ID, time window, workload, identity and the authoritative configuration/policy source for SELinux Troubleshooting. - 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 | symptom/time → reproduce under known mode → correlate AVC/audit event → inspect subject/object context + policy/boolean → minimal persistent remediation → enforcing retest → regression Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. |
| Failure boundary | Troubleshooting closes only when the first SELinux boundary is proven, corrected minimally/persistently and the original workload succeeds in enforcing mode without unrelated policy broadening. 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. |