Diagnosing SELinux AVC denials
Author: DEWOLF.IT
Read AVC denials, verify labels and choose an appropriately narrow SELinux change on RHEL.
This English edition covers the main steps. See the Dutch article for the full detail and examples.
Connect the denial to the failed action
Correlate the relevant AVC with the service log and timestamp. Read the process and object contexts, object class and denied operation. Check discretionary permissions and service isolation as well.
getenforce
sudo ausearch -m AVC,USER_AVC -ts recent
ls -Zd /path
matchpathcon -V /path
Decide whether the label is wrong
Compare the effective label with the expected file context. Restore the expected label where appropriate. If a custom directory is part of the design, review a persistent file-context definition before applying it. A one-off label change can be lost during relabelling.
Choose a narrowly scoped change
Check whether an existing boolean, permitted port type or vendor-documented configuration expresses the intended access. Review the need and exact permissions before introducing local policy. Avoid generating broad access rules solely from observed denials.
Prove intended access and confinement
Retest the service with enforcement enabled, verify that the earlier denied operation now behaves as intended and check that the change did not grant unrelated access.
Check the SELinux guidance for your release in the RHEL documentation.
