⬢ DragonFlyBSD Kernel Audit
DF-5606 / proof.sh
← back to finding ↓ download raw
#!/bin/sh
# DF-5606 static proof (HOST side, from repo root): the u4b orphan is doubly dead.
#   A. no build target anywhere references sys/bus/u4b/net/ruephy.c
#   B. its FreeBSD include layout does not exist in this tree
#   C. the FreeBSD new-mii API it calls does not exist in DragonFly's mii core
#      (only vestige: commented-out remnants in atphy.c:99,114)
#   D. the API-delta table: orphan call sites vs DragonFly mii_layer decls
# Run:  sh findings/poc/DF-5606/proof.sh
set -e
cd "$(dirname "$0")/../../.."

fail() { echo "PROOF FAILED: $1" >&2; exit 1; }

echo "== A. no build target references the orphan =="
A=$(grep -rn 'u4b/net/ruephy' sys/conf/ sys/bus/u4b/Makefile sys/bus/u4b/net/Makefile \
    sys/bus/u4b/*/Makefile sys/bus/u4b/net/*/Makefile 2>/dev/null | wc -l)
[ "$A" -eq 0 ] || fail "a build file references the orphan"
echo "   OK: zero references in conf/files, u4b Makefiles, net module Makefiles"

echo "== B. FreeBSD include layout absent =="
[ -d sys/dev/mii ]      && fail "sys/dev/mii exists (re-check!)"
[ -d sys/dev/usb ]      && fail "sys/dev/usb exists (re-check!)"
echo "   OK: neither sys/dev/mii nor sys/dev/usb exists; real homes are"
echo "       sys/dev/netif/mii_layer and sys/bus/u4b"

echo "== C. FreeBSD new-mii API absent from DragonFly mii core =="
# atphy.c carries the same FreeBSD-HEAD vestiges, all disabled: :89 sits
# inside an `#if 0` block (:86-:92), :99 and :114 are comments.
C=$(grep -rn -e 'mii_phy_dev_probe' -e 'mii_phy_dev_attach' -e 'mii_phy_detach' \
             -e 'MII_PHY_END' -e 'MIIF_NOMANPAUSE' -e 'mii_phy_funcs' \
             sys/dev/netif/mii_layer/ | \
    grep -v -e 'atphy.c:89' -e 'atphy.c:99' -e 'atphy.c:114' | wc -l)
[ "$C" -eq 0 ] || fail "FreeBSD new-mii symbol present in mii_layer (re-check!)"
echo "   OK: mii.c/miivar.h/mii_physubr.c define none of them"
echo "       (only in-tree vestiges: atphy.c:89 (#if 0 block), :99/:114 (comments))"

echo "== D. API-delta table (orphan call site -> DragonFly reality) =="
echo "   ruephy.c:47  <dev/mii/mii.h>           -> sys/dev/netif/mii_layer/mii.h   (different path)"
echo "   ruephy.c:51  <dev/usb/net/ruephyreg.h> -> sys/bus/u4b/net/ruephyreg.h     (different path)"
echo "   ruephy.c:62  mii_phy_detach            -> absent; twin uses ukphy_detach (miivar.h:276)"
echo "   ruephy.c:87  MII_PHY_END               -> absent; DF uses MII_PHYDESC_NULL (miivar.h:191)"
echo "   ruephy.c:90  struct mii_phy_funcs      -> absent"
echo "   ruephy.c:102 mii_phy_dev_probe         -> absent; DF uses mii_phy_match (miivar.h:266)"
echo "   ruephy.c:110 mii_phy_dev_attach        -> absent; DF attaches manually (twin :104-149)"
echo "   ruephy.c:110 MIIF_NOMANPAUSE           -> absent (MIIF_NOISOLATE exists, miivar.h:138)"
echo "   ruephy.c:132 mii_phy_setmedia          -> DF name: mii_phy_set_media (miivar.h:260)"
echo "   ruephy.c:164 mii_phy_auto(sc) 1-arg    -> DF proto: mii_phy_auto(sc, int) (miivar.h:270)"
echo "   ruephy.c:86  mii_phydesc{0,0,name}     -> DF struct has 4 members incl. mpd_priv (miivar.h:186-193)"

echo
echo "PROOF OK: the orphan is unreferenced by any build target and cannot compile"
echo "against this tree's mii API; it cannot become live without importing the"
echo "FreeBSD new-mii core wholesale (which would then revive the latent family"
echo "defects: unguarded ifm_cur derefs at ruephy.c:145/:231 and the DF-5001"
echo "empty-media attach-panic branch)."