Skip to content

Commit 88984c9

Browse files
committed
docs(quick-deploy): expand SELinux troubleshooting with specific context fixes for ethtool, df, postgresql, python3, etc
1 parent b91cb07 commit 88984c9

File tree

1 file changed

+98
-23
lines changed

1 file changed

+98
-23
lines changed

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

Lines changed: 98 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,50 +1280,125 @@ Our `perfSONAR-update-lsregistration.sh` helper attempts to automatically apply
12801280
sudo systemctl restart perfsonar-lsregistrationdaemon
12811281
```
12821282
1283-
#### Issue 2: Other Services (ethtool, df, python3, etc.) Generating Audit Alerts
1283+
#### Issue 2: Other Services (ethtool, df, python3, postgresql, collect2) Generating Audit Alerts
12841284
1285-
**Symptoms:** Audit log shows alerts for `ethtool`, `df`, `python3.9`, `collect2`, etc.:
1285+
**Symptoms:** Audit log shows alerts for various tools running in unexpected SELinux contexts:
12861286
```
12871287
SELinux is preventing /usr/sbin/ethtool from setopt access on netlink_generic_socket labeled httpd_t.
1288+
SELinux is preventing /usr/bin/df from getattr access on the directory /var/cache/openafs.
1289+
SELinux is preventing /usr/bin/python3.9 from execute access on the file ldconfig.
1290+
SELinux is preventing /usr/libexec/gcc/x86_64-redhat-linux/11/collect2 from search access on the directory snapd.
12881291
```
12891292
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)
1293+
**Root cause:** These alerts typically stem from:
1294+
- Tools invoked from web interfaces or services running in different SELinux contexts (e.g., `httpd_t`, `postgresql_t`)
1295+
- Third-party or system utilities that lack complete SELinux policy coverage
1296+
- Legitimate operations conflicting with default policy rules
1297+
- Build/compilation tools invoked during package installation (usually transient)
12941298
1295-
**Assessment:**
1299+
**Assessment and diagnosis:**
12961300
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:**
1301+
1. **Check if the alert is related to perfSONAR functionality:**
1302+
13021303
```bash
13031304
# View recent audit alerts
1304-
tail -50 /var/log/audit/audit.log
1305+
tail -100 /var/log/audit/audit.log
13051306
1306-
# Filter by specific service
1307-
grep "ethtool" /var/log/audit/audit.log | tail -10
1307+
# Filter by command name to see context
1308+
grep "ethtool\|df\|python\|collect2\|ldconfig" /var/log/audit/audit.log | head -20
1309+
1310+
# Count alert types to identify patterns
1311+
ausearch -m AVC | awk -F'avc:' '{print $2}' | sort | uniq -c | sort -rn | head -10
13081312
```
13091313
1310-
3. **Generate a local policy module (if needed):**
1314+
2. **Determine the source process and context:**
1315+
1316+
- Alerts mentioning `httpd_t` usually indicate the web UI triggered the operation (typically safe to allow)
1317+
- Alerts from `postgresql_t` indicate database tools being invoked (context boundary may not be required)
1318+
- Alerts from `lsregistrationdaemon_t` indicate the registration daemon needs access (fix labels first, not policies)
1319+
- Alerts from `gcc/collect2` during package install are usually transient (monitor periodically)
1320+
1321+
3. **Create a local SELinux policy module** (if operation is verified as safe)
1322+
13111323
```bash
1312-
# Create a policy module for a specific alert (example: ethtool)
1324+
# Generate policy module for a specific alert (example: ethtool)
13131325
sudo ausearch -c 'ethtool' --raw | audit2allow -M my-ethtool
13141326
1315-
# Review the generated policy
1327+
# Review the generated module to ensure it's safe
13161328
cat my-ethtool.te
13171329
1318-
# Install the module (if the policy is acceptable)
1330+
# Install the module (if approved and safe)
13191331
sudo semodule -i my-ethtool.pp
1332+
1333+
# Verify installation
1334+
semodule -l | grep my-ethtool
13201335
```
13211336
1322-
**Mitigation strategies:**
1337+
**Specific service fixes:**
1338+
1339+
**ethtool netlink access (from httpd_t or lsregistrationdaemon_t):**
1340+
- **Operation:** Checking NIC link status, speed, duplex (safe)
1341+
- **Source:** Web UI health checks or daemon monitoring
1342+
- **Fix:**
1343+
```bash
1344+
sudo ausearch -c 'ethtool' --raw | audit2allow -M my-ethtool
1345+
sudo semodule -i my-ethtool.pp
1346+
```
1347+
1348+
**df/stat on /var/cache/openafs (from lsregistrationdaemon_t):**
1349+
- **Operation:** Checking available disk space (safe)
1350+
- **Source:** Registration daemon system health queries
1351+
- **Fix:**
1352+
```bash
1353+
sudo ausearch -c 'df' --raw | audit2allow -M my-df
1354+
sudo semodule -i my-df.pp
1355+
```
1356+
1357+
**python3/postgresql context issues (collect2, ldconfig):**
1358+
- **Operation:** Build tools, library checks during package installation (usually transient)
1359+
- **Assessment:** These are typically safe but may be ephemeral
1360+
- **Fix (if persistent):**
1361+
```bash
1362+
# For postgresql-related alerts
1363+
sudo ausearch -c 'validate-config' --raw | audit2allow -M my-postgresql
1364+
sudo semodule -i my-postgresql.pp
1365+
```
1366+
1367+
**Audit log monitoring (prevents future surprises):**
1368+
1369+
```bash
1370+
# Check for recent AVC denials
1371+
sudo ausearch -m AVC -ts recent | tail -50
1372+
1373+
# Create a daily monitoring script
1374+
cat > /usr/local/bin/check-selinux-alerts.sh << 'EOF'
1375+
#!/bin/bash
1376+
# Check for recent SELinux audit alerts
1377+
1378+
RECENT_ALERTS=$(ausearch -m AVC -ts recent 2>/dev/null | wc -l)
1379+
1380+
if [ $RECENT_ALERTS -gt 0 ]; then
1381+
echo "WARNING: Found $RECENT_ALERTS recent SELinux alerts:"
1382+
ausearch -m AVC -ts recent | tail -20
1383+
else
1384+
echo "OK: No recent SELinux audit alerts"
1385+
fi
1386+
EOF
1387+
1388+
chmod 0755 /usr/local/bin/check-selinux-alerts.sh
1389+
1390+
# Add to cron (runs daily at 9 AM)
1391+
echo "0 9 * * * root /usr/local/bin/check-selinux-alerts.sh" | sudo tee /etc/cron.d/selinux-alert-check
1392+
```
1393+
1394+
**Best practice for handling alerts:**
1395+
1396+
1. Log all alerts for 1-2 weeks to establish a baseline
1397+
2. Review and categorize (safe vs. unsafe operations)
1398+
3. Create local policy modules only for verified, safe operations
1399+
4. Document each module in your change log
1400+
5. Monitor weekly for new or unexpected alerts
13231401
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
13271402
13281403
#### Issue 3: Audit Log Flooding
13291404

0 commit comments

Comments
 (0)