โฌข DragonFlyBSD Kernel Audit
DF-1078 / verify.sh
โ† back to finding โ†“ download raw
#!/bin/sh
# DF-1078 โ€” vkernel64 DDB backtrace leaks kernel addresses to msgbuf.
# Static source verification (runtime needs a running vkernel64 binary, which
# is a separate non-default kernel build โ€” not the running GENERIC kernel).

set -e
F=sys/platform/vkernel64/x86_64/db_trace.c

echo "=== (1) raw rip/rsp/rbp prints in db_nextframe TRAP/SYSCALL/INTERRUPT cases ==="
sed -n '278,303p' "$F"

echo
echo "=== (2) %p stack-frame address prints in db_stack_trace_cmd ==="
sed -n '343,354p' "$F"

echo
echo "=== (3) vkernel64 is MISSING the Xfast_syscall boundary stop ==="
echo "vkernel64 db_trace.c (expect no match):"
grep -nE "Xfast_syscall" "$F" || echo "  (no Xfast_syscall stop in vkernel64 โ€” confirmed missing)"
echo "pc64 db_trace.c sibling (has the stop):"
grep -nE "Xfast_syscall" sys/platform/pc64/x86_64/db_trace.c

echo
echo "=== (4) db_putchar routes to kprintf -> msgbuf when !db_active ==="
sed -n '100,125p' sys/ddb/db_output.c

echo
echo "=== (5) VKERNEL64 config enables DDB + DDB_TRACE + INVARIANTS by default ==="
grep -nE "DDB|INVARIANTS" sys/config/VKERNEL64 2>/dev/null | head

echo
echo "=== (6) vkernel64 is NOT the running kernel (GENERIC is) ==="
./dfbsd-qemu/vm.sh run_root 'sysctl -n kern.version | head -1; ls /boot/kernel/ | grep -i vkernel' 2>/dev/null
echo "(no vkernel module/binary listed = VKERNEL64 is a separate user-mode kernel build)"

echo
echo "DONE: all six static checks executed."