Skip to content

Commit b91cb07

Browse files
committed
docs(quick-deploy): add SELinux troubleshooting section with lsregistrationdaemon context fix
1 parent 5aed8f3 commit b91cb07

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

docs/personas/quick-deploy/install-perfsonar-toolkit.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,145 @@ podman exec -it perfsonar-testpoint psconfig remote list
12181218
12191219
---
12201220
1221+
## Step 9 – SELinux Troubleshooting (If Enabled)
1222+
1223+
If you've enabled SELinux in enforcing mode, certain perfSONAR operations may generate audit log alerts. This section explains common issues and their fixes.
1224+
1225+
### SELinux Basics for perfSONAR
1226+
1227+
SELinux enforces mandatory access controls based on file labels and process contexts. perfSONAR services run under specific contexts (e.g., `lsregistrationdaemon_t`, `httpd_t`), and accessed files must have compatible labels.
1228+
1229+
**Check SELinux status:**
1230+
1231+
```bash
1232+
sestatus
1233+
# Expected output: "SELinux status: enabled" and "Current mode: enforcing"
1234+
```
1235+
1236+
### Common SELinux Issues and Fixes
1237+
1238+
#### Issue 1: `/etc/perfsonar/lsregistrationdaemon.conf` Has Wrong Label
1239+
1240+
**Symptom:** Audit log shows:
1241+
```
1242+
SELinux is preventing /usr/bin/perl from getattr access on the file /etc/perfsonar/lsregistrationdaemon.conf.
1243+
```
1244+
1245+
**Root cause:** The configuration file was created or modified (e.g., via restore or manual edit) and has an incorrect SELinux label. The file should be labeled `lsregistrationdaemon_etc_t` but may be labeled `admin_home_t` or have no label.
1246+
1247+
**Fix: Apply `restorecon` to relabel the file:**
1248+
1249+
```bash
1250+
# Restore the default SELinux context for the file
1251+
sudo /sbin/restorecon -v /etc/perfsonar/lsregistrationdaemon.conf
1252+
1253+
# Verify the label is now correct
1254+
ls -Z /etc/perfsonar/lsregistrationdaemon.conf
1255+
# Expected: system_u:object_r:lsregistrationdaemon_etc_t:s0
1256+
```
1257+
1258+
**Automatic fix during restore:**
1259+
1260+
Our `perfSONAR-update-lsregistration.sh` helper attempts to automatically apply `restorecon` after writing the configuration file. If `restorecon` is available on your system, it runs without user intervention:
1261+
1262+
```bash
1263+
# Use the helper to restore config (with automatic restorecon attempt)
1264+
/opt/perfsonar-toolkit/tools_scripts/perfSONAR-update-lsregistration.sh restore --local \
1265+
--input ./my-lsreg.conf
1266+
1267+
# Or extract and run a self-contained restore script
1268+
/opt/perfsonar-toolkit/tools_scripts/perfSONAR-update-lsregistration.sh extract --local \
1269+
--output ./restore-lsreg.sh
1270+
./restore-lsreg.sh # This script includes a restorecon attempt
1271+
```
1272+
1273+
**Preventing the issue:**
1274+
1275+
- Always use the helper script (`perfSONAR-update-lsregistration.sh`) for configuration changes, as it handles `restorecon` automatically.
1276+
- After any manual edits to `/etc/perfsonar/lsregistrationdaemon.conf`, explicitly run `restorecon`:
1277+
```bash
1278+
sudo vi /etc/perfsonar/lsregistrationdaemon.conf
1279+
sudo /sbin/restorecon -v /etc/perfsonar/lsregistrationdaemon.conf # Fix labels immediately
1280+
sudo systemctl restart perfsonar-lsregistrationdaemon
1281+
```
1282+
1283+
#### Issue 2: Other Services (ethtool, df, python3, etc.) Generating Audit Alerts
1284+
1285+
**Symptoms:** Audit log shows alerts for `ethtool`, `df`, `python3.9`, `collect2`, etc.:
1286+
```
1287+
SELinux is preventing /usr/sbin/ethtool from setopt access on netlink_generic_socket labeled httpd_t.
1288+
```
1289+
1290+
**Root cause:** These are typically due to:
1291+
- Overly restrictive SELinux policies for third-party tools
1292+
- Legitimate operations that conflict with SELinux policy defaults
1293+
- Tools running in unexpected contexts (e.g., under `httpd_t` or `postgresql_t` instead of intended domain)
1294+
1295+
**Assessment:**
1296+
1297+
1. **Determine if the alert is a real security issue:**
1298+
- If the operation is expected and safe, the alert can usually be ignored or a local policy module can be created.
1299+
- If the operation is unexpected, investigate why the process is running in that context.
1300+
1301+
2. **Check the audit log for details:**
1302+
```bash
1303+
# View recent audit alerts
1304+
tail -50 /var/log/audit/audit.log
1305+
1306+
# Filter by specific service
1307+
grep "ethtool" /var/log/audit/audit.log | tail -10
1308+
```
1309+
1310+
3. **Generate a local policy module (if needed):**
1311+
```bash
1312+
# Create a policy module for a specific alert (example: ethtool)
1313+
sudo ausearch -c 'ethtool' --raw | audit2allow -M my-ethtool
1314+
1315+
# Review the generated policy
1316+
cat my-ethtool.te
1317+
1318+
# Install the module (if the policy is acceptable)
1319+
sudo semodule -i my-ethtool.pp
1320+
```
1321+
1322+
**Mitigation strategies:**
1323+
1324+
- **Monitor periodically:** Run `ausearch -m AVC -ts recent` weekly to catch emerging issues
1325+
- **Create local policies sparingly:** Only add modules for verified, safe operations
1326+
- **Contact perfSONAR maintainers:** If alerts affect core perfSONAR functionality, report the issue to the perfSONAR project
1327+
1328+
#### Issue 3: Audit Log Flooding
1329+
1330+
**Symptom:** Audit log grows very large due to repeated identical alerts.
1331+
1332+
**Mitigation:**
1333+
1334+
```bash
1335+
# View count of each AVC alert type
1336+
ausearch -m AVC | awk -F'avc:' '{print $2}' | sort | uniq -c | sort -rn | head -20
1337+
1338+
# Suppress specific alerts (if they are verified as safe):
1339+
# Add rules to /etc/audit/audit.rules or /etc/audit/rules.d/
1340+
# (requires audit service restart and SELinux expertise)
1341+
```
1342+
1343+
### Best Practices for SELinux with perfSONAR
1344+
1345+
1. **Use automated tools:** Always use the helper scripts (`perfSONAR-update-lsregistration.sh`, `perfSONAR-install-nftables.sh`) which handle SELinux contexts automatically.
1346+
1347+
2. **Run `restorecon` after manual edits:** If you manually edit any perfSONAR configuration file, immediately restore the SELinux context:
1348+
```bash
1349+
sudo /sbin/restorecon -v /path/to/file
1350+
```
1351+
1352+
3. **Monitor audit logs regularly:** Check `/var/log/audit/audit.log` weekly to catch new issues early.
1353+
1354+
4. **Document exceptions:** If you create local SELinux policy modules, document them in your change log so future admins understand why they exist.
1355+
1356+
5. **Keep policies minimal:** Only add local policy modules for operations that are verified as safe and necessary. Overly permissive policies increase security risk.
1357+
1358+
---
1359+
12211360
## Step 9 – Post-Install Validation
12221361
12231362
Perform these checks before handing the host over to operations:

0 commit comments

Comments
 (0)