DragonFlyBSD Kernel Audit
DF-0606 / repro.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-0606 repro.sh — original (theoretical) live-DDB reproduction.
#
# REQUIRES: IEEE80211 (WiFi) hardware with an active MBSS mesh vap that has
# at least one entry in ms_routes. This KVM audit guest has no WiFi hardware
# (vtnet0/lo0 only), so this script cannot be exercised here. It is kept as
# the documented live procedure for a system that does have a mesh vap.
#
# Run as root on a DFly system with a real wlan adapter in mesh mode.

set -eu

echo "Enter DDB via sysctl (or by provoking a wlan panic with debugger_on_panic=1):"
echo "    sysctl debug.enter_debugger=ddb        # root: drops to db> prompt"
echo
echo "At the db> prompt, type one of:"
echo "    db> show mesh <mesh-state-addr>        # addr of an ieee80211_mesh_state"
echo "    db> show vap  <mesh-vap-addr> m        # vap whose iv_opmode==IEEE80211_M_MBSS"
echo "    db> show com  <mesh-ic-addr> a         # com whose vap list has a mesh vap"
echo
echo "EXPECTED on the BUGGY kernel:"
echo "  - ddb hangs (lockmgr deadlock in frozen scheduler), OR"
echo "  - double-fault -> immediate reboot (Fatal double fault / re-entering trap"
echo "    from inside ddb), destroying forensic state, OR"
echo "  - if it returns: running the command twice shows rt_lifetime collapsing"
echo "    to 0 and rt_flags losing VALID on previously-good routes."
echo
echo "EXPECTED on the FIXED kernel:"
echo "  - command prints routing table cleanly and returns; no table mutation."

# --- the rest is only run if the script is invoked on a mesh-capable box ---
if ! ifconfig -l 2>/dev/null | tr ' ' '\n' | grep -q '^wlan'; then
    echo
    echo "NOT RUN: no wlan interface present (ifconfig -l: $(ifconfig -l 2>/dev/null))."
    echo "Use verify.sh baseline/patched for the disassembly-level proof."
    exit 0
fi

# only reached if a wlan device exists
IFACE="${WLAN:-wlan0}"
ifconfig "$IFACE" create wlandev "${WLANDEV:-wifi0}" wlanmode mesh 2>/dev/null || true
ifconfig "$IFACE" up 2>/dev/null || true
ifconfig "$IFACE" list mesh 2>/dev/null || true
sysctl debug.enter_debugger=ddb