⬢ DragonFlyBSD Kernel Audit
DF-4057 / s4_run.sh
← back to finding ↓ download raw
#!/bin/sh
# S4: run the deadlock scenario in background; observe after 8s
cd /root/dfet
K=/boot/kernel/kernel
A_INTR=$(nm $K | awk '/ t et_intr$/{print $1; exit}')
A_TXEOF=$(nm $K | awk '/ t et_txeof$/{print $1; exit}')
A_STOP=$(nm $K | awk '/ t et_stop$/{print $1; exit}')
A_TICK=$(nm $K | awk '/ t et_tick$/{print $1; exit}')
A_NBHDR=$(nm $K | awk '/ t et_newbuf_hdr$/{print $1; exit}')
A_NBCL=$(nm $K | awk '/ t et_newbuf_cluster$/{print $1; exit}')
test -n "$A_INTR" -a -n "$A_TXEOF" -a -n "$A_STOP" -a -n "$A_TICK" -a -n "$A_NBHDR" -a -n "$A_NBCL"
kldload ./dfet_poc.ko
sysctl -w kern.dfet.intr=0x$A_INTR >/dev/null
sysctl -w kern.dfet.txeof=0x$A_TXEOF >/dev/null
sysctl -w kern.dfet.stop=0x$A_STOP >/dev/null
sysctl -w kern.dfet.tick=0x$A_TICK >/dev/null
sysctl -w kern.dfet.nbhdr=0x$A_NBHDR >/dev/null
sysctl -w kern.dfet.nbcl=0x$A_NBCL >/dev/null
echo "armed; dispatching go=4 in background (stopper thread)..."
(sysctl -w kern.dfet.go=4 > /tmp/s4_go.out 2>&1) &
sleep 8
echo "=== dmesg S4 markers (last line must be the AB-BA marker if deadlocked):"
dmesg | grep 'dfet: S4' | tail -5
echo "=== s4_go.out (empty = sysctl never returned):"
cat /tmp/s4_go.out
echo "(end)"
echo "=== thread states (stopper 'costp' + softclock 'slize'):"
ps -o pid,stat,wchan,pcpu,command -ax | grep -E "go=4|softclock" | grep -v grep
echo "=== second sample after +5s (permanence):"
sleep 5
dmesg | grep -c 'S4: REAL et_stop RETURNED'
dmesg | grep 'dfet: S4' | tail -1
uptime