Skip to content

Commit 213f7b6

Browse files
committed
add auditd to see what is changign the ownership
Signed-off-by: Simon Davies <[email protected]>
1 parent 9614326 commit 213f7b6

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

.github/workflows/dep_rust.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,31 @@ jobs:
4949
steps:
5050
- uses: actions/checkout@v4
5151

52+
# Set up auditd monitoring for /dev/kvm permission changes
53+
- name: Setup auditd monitoring for hypervisor devices
54+
if: runner.os == 'Linux'
55+
run: |
56+
echo "Setting up auditd monitoring for hypervisor devices..."
57+
# Install auditd if not present
58+
if ! command -v auditctl &> /dev/null; then
59+
if command -v dnf &> /dev/null; then
60+
sudo dnf install -y audit
61+
elif command -v apt &> /dev/null; then
62+
sudo apt update && sudo apt install -y auditd
63+
fi
64+
fi
65+
66+
# Start auditd service
67+
sudo systemctl start auditd || sudo service auditd start || echo "Failed to start auditd, continuing..."
68+
69+
# Add audit rules for /dev/kvm and /dev/mshv
70+
sudo auditctl -w /dev/kvm -p wa -k hypervisor_kvm || echo "Failed to add KVM audit rule"
71+
sudo auditctl -w /dev/mshv -p wa -k hypervisor_mshv || echo "Failed to add MSHV audit rule"
72+
73+
# List current audit rules
74+
echo "Current audit rules:"
75+
sudo auditctl -l || echo "Failed to list audit rules"
76+
5277
# For rust-fmt
5378
- name: Set up nightly rust
5479
uses: dtolnay/rust-toolchain@nightly
@@ -204,3 +229,22 @@ jobs:
204229
echo ""
205230
echo "CPU virtualization features:"
206231
grep -E "(vmx|svm)" /proc/cpuinfo | head -5 || echo "No CPU virtualization features found"
232+
echo ""
233+
echo "=== Auditd Log Analysis ==="
234+
echo "Hypervisor device audit events (KVM):"
235+
sudo ausearch -k hypervisor_kvm -ts today 2>/dev/null || echo "No KVM audit events found or ausearch failed"
236+
echo ""
237+
echo "Hypervisor device audit events (MSHV):"
238+
sudo ausearch -k hypervisor_mshv -ts today 2>/dev/null || echo "No MSHV audit events found or ausearch failed"
239+
echo ""
240+
echo "Recent audit log entries (last 50 lines):"
241+
sudo tail -50 /var/log/audit/audit.log 2>/dev/null || echo "Unable to read audit log"
242+
echo ""
243+
echo "File access audit events for /dev/kvm:"
244+
sudo ausearch -f /dev/kvm -ts today 2>/dev/null || echo "No /dev/kvm access events found"
245+
echo ""
246+
echo "File access audit events for /dev/mshv:"
247+
sudo ausearch -f /dev/mshv -ts today 2>/dev/null || echo "No /dev/mshv access events found"
248+
echo ""
249+
echo "Permission change events:"
250+
sudo ausearch -sc chmod,fchmod,chown,fchown,lchown -ts today 2>/dev/null | grep -E "(kvm|mshv)" || echo "No permission change events for hypervisor devices found"

0 commit comments

Comments
 (0)