Diagnosing SELinux AVC Denials on Fedora Workstation and Server
How to read AVC denials, check SELinux booleans and file contexts, and apply targeted fixes on Fedora without disabling SELinux.
06 Aug 2025, 11:52 UTC

The problem: permission denied with correct file permissions
An application on Fedora starts successfully but cannot read a configuration file, write to its data directory, or bind to a port. The standard ownership and mode look correct, yet the process receives Permission denied. On Fedora Workstation and Server, SELinux runs in enforcing mode by default with the targeted policy. A mandatory access control check can block the operation even when discretionary access control (DAC) permissions allow it.
The useful takeaway: you do not need to disable SELinux. Recent denials are recorded in the audit log as AVC (Access Vector Cache) messages. You can identify the missing rule from those messages and apply a targeted fix such as toggling a boolean, restoring a file context, or installing a local policy module.
Recognizable condition
Look for this combination:
- The application logs
Permission deniedor fails to start. journalctl,dmesg, or/var/log/audit/audit.logcontainsavc: deniedortype=AVCentries.- The entry shows
scontext(source process label) andtcontext(target object label) that do not match an allowed rule.
Cause and diagnostic table
| Observed condition | Likely cause | First check |
|---|---|---|
Permission denied despite correct owner and mode; avc: denied in logs | Missing SELinux boolean or incorrect file context | sudo ausearch -m avc -ts recent |
ps -eZ shows unconfined_u for the service | Process is not running in a confined SELinux domain | Inspect the systemd unit and service documentation |
| New application behavior has no matching allow rule | Policy gap for the application's domain | sudo sealert -a /var/log/audit/audit.log |
| Files copied or restored from another system | File context labeling was lost | matchpathcon -V /path/to/file |
Ordered checks
- Capture recent denials. Run on the Fedora host with
sudoor as root. This requires auditd to be running.
Expected output: one or moresudo ausearch -m avc -ts recenttype=AVCrecords withscontext,tcontext,tclass, andopfields. Read-only; no risk. - Get a human-readable suggestion.
Or for a single alert UUID:sudo sealert -a /var/log/audit/audit.logsudo sealert -l <alert_uuid>. Review the suggested fix before applying it. - Check relevant booleans.
Replacegetsebool -a | grep -i <keyword><keyword>with the service name, such ashttpdornamed. A boolean is a named SELinux policy switch that permits or denies a class of actions. - Verify file contexts.
Expected result:matchpathcon -V /path/to/fileverifiedor a mismatch showing the current context and the expected context. Read-only. - Diagnose with a permissive domain only if needed.
This logs denials forsudo semanage permissive -a <domain_t><domain_t>but does not block them. Use only for diagnosis, not production. Remove it later withsudo semanage permissive -d <domain_t>. - Generate a candidate local policy module.
Inspectsudo audit2allow -M localfix < /var/log/audit/audit.loglocalfix.tebefore compiling.audit2allowmay over-permit by allowing every recorded denial.
Fixes tied to findings
Missing boolean
If getsebool shows the boolean off, enable it persistently:
sudo setsebool -P httpd_can_network_connect onReplace httpd_can_network_connect with the boolean suggested by sealert. The -P flag writes the setting to disk so it survives reboots. Rollback: sudo setsebool -P httpd_can_network_connect off.Wrong file context
Restore the default context:
sudo restorecon -Rv /srv/myappTo make the correct context survive future relabels, add a file context rule first:sudo semanage fcontext -a -t httpd_sys_content_t '/srv/myapp(/.*)?'
sudo restorecon -Rv /srv/myappReplace httpd_sys_content_t and the path with values from matchpathcon or sealert. Rollback: remove the rule with sudo semanage fcontext -d '/srv/myapp(/.*)?' and run restorecon again.Policy gap for a local application
Compile and install the reviewed module:
sudo semodule -i localfix.ppSet a higher priority so Fedora policy updates are less likely to shadow it:sudo semodule -X 400 -i localfix.ppRollback: sudo semodule -r localfix.Lost labeling after restore or copy
Trigger a full relabel on the next boot:
sudo touch /.autorelabelThen reboot. This can take 10 to 30 minutes on large disks; schedule a maintenance window. Rollback: remove /.autorelabel before rebooting if you need to cancel.Escalation criteria
- The denial involves a kernel subsystem such as netlink or BPF: file a kernel bug rather than writing a local policy.
- The fix requires an upstream policy change: report to the SELinux policy project with
ausearchoutput and the Fedora version. - A local module does not stop the denial: ask a maintainer to check whether dontaudit rules are masking secondary denials.
- The problem appeared after a Fedora upgrade: file a Fedora Bugzilla report including
dnf historyoutput and the installedselinux-policyversion.
Verification
sestatusshould reportSELinux status: enabledandCurrent mode: enforcing.- Run
sudo ausearch -m avc -ts today | wc -lbefore and after the fix; the count for the target service should drop to zero. - Restart the workload, for example
sudo systemctl restart httpd, and watchsudo journalctl -f -t auditfor new AVC messages. matchpathcon -V /path/to/filereturnsverified.getsebool <bool_name>showson.semodule -l | grep localfixconfirms the custom module is loaded.
Limitations
- Never disable SELinux globally (
setenforce 0orselinux=0) as a permanent fix; it removes mandatory access control for all processes. - Permissive domains log but do not block; remove them after diagnosis.
- Custom modules from
audit2allowcan over-permit. Review the.tefile before compiling. - Fedora
selinux-policyupdates can override local modules; use module priority or re-test after updates. - Container runtimes such as Podman use separate labels (
container_t,container_file_t); host policy changes do not automatically apply inside containers.
These steps cover well-established behavior on Fedora 38 through 41 with the default targeted policy. If a denial persists after the checks above, collect the ausearch output and escalate rather than weakening system policy.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.