β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-5090

ruephy(4) is dead code β€” unreachable carrier of the DF-4930/DF-5001 empty-media attach-panic leaf and the DF-1973/DF-5009 service KASSERT: no NIC driver named "rue" exists anywhere in DragonFly

Summary

The probe gates on a grandparent named 'rue' but the RTL8150 USB NIC driver was never ported (no DRIVER_MODULE, no config, no if_rue.c; the u4b copy is an unreferenced orphan). The audited copy IS compiled into miibus, probing every MII child and always ENXIO. A future rue(4) port instantly activates the INVARIANTS-live service KASSERT + the empty-media attach panic unless the DF-5001 hub guard lands with it. Seven-invariant static proof script; Phase V exempt (trigger unconstructible). Delete-the-dead-driver fix.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-5090 Β· 6 files
FileTypeDescriptionSize
README.md β€” 2.3 KB ↓ raw
VERDICT.md β€” 4.6 KB ↓ raw
proof.sh β€” 3.1 KB view raw
proof.log β€” 1.2 KB view raw
manifest.json β€” 1.3 KB view raw
verdict.json β€” 4.7 KB view raw

DF-5090 β€” ruephy(4) is dead code: unreachable latent leaf of the mii attach-panic family

File audited: sys/dev/netif/mii_layer/ruephy.c (284 LOC, pass 2)

What this pack proves (statically β€” no guest applicable)

ruephy_probe() (ruephy.c:96) only accepts a miibus child whose grandparent device name is exactly "rue" β€” the Realtek RTL8150 USB NIC driver. No driver, devclass, kernel config entry, or module named rue exists anywhere in this tree. Therefore ruephy_attach/_service/_status/_reset are unreachable on every kernel buildable from this source, and the three latent family defects below can never fire today:

  1. Empty-media attach panic (ruephy.c:141-145) β€” DF-4930/DF-4957/DF-4981/ DF-5003/DF-5053 leaf family, hub DF-5001: no media present branch skips mii_phy_add_media(), so miibus_mediainit (mii.c:228-245) calls ifmedia_set() on an empty list β†’ panic("ifmedia_set").
  2. Service-entry KASSERT (ruephy.c:161) β€” DF-1973/DF-5009 family; note DragonFly stock X86_64_GENERIC enables INVARIANTS (config line 56), so this assert is live on stock kernels β€” held in check only by the probe gate and by the non-zero-instance refusal at ruephy.c:121-124.
  3. Unguarded ifm_cur deref (ruephy.c:282) in the forced-media branch of ruephy_status() β€” shared upstream pattern; NULL only via path (1).

Reproduce

cd /home/maxx/dfbsd/dfbsd
sh findings/poc/DF-5090/proof.sh        # exit 0 + "PROOF OK"

Expected: all seven invariants hold (proof.log); decisive output is section A β€” the only "rue" string literals in the entire tree are ruephy.c's own probe gates.

Why no QEMU run

Phase V is exempt for Info hardening findings. Beyond the exemption, a runtime PoC is unconstructible: triggering attach requires a rue NIC driver, which does not exist; manufacturing a fake one on the guest would demonstrate the already-replay-proven DF-4930 family mechanism (see the truephy/qsphy packs), not anything new about this file. The exhaustive tree/build-system proof here is strictly stronger than any single-guest observation.

Fix

Retire the driver (and its ruephyreg.h, plus the never-compiled u4b orphans sys/bus/u4b/net/ruephy.c + ruephyreg.h). If rue(4) is ever ported, the DF-5001 hub guard must land with it.

VERDICT.md
↓ download raw

VERDICT β€” DF-5090 (ruephy.c dead code / unreachable family leaf)

Status: untested (static verification, Phase V exempt β€” Info finding, no runtime trigger constructible). Impact: none (today). Confidence: certain. Attempts: 0 (no guest run).

What was audited

Full pass-2 audit of sys/dev/netif/mii_layer/ruephy.c (284 LOC) against the mii family checklist (empty-media branch, service KASSERT, status decode, reset, probe sentinel, reachability), plus full pass-2 audit of the consumer chain: probe/attach/service/status call paths, mii.c (miibus_mediainit, mii_softc_init, mii_phy_add_media), mii_physubr.c (mii_phy_reset, mii_phy_update), ukphy.c (ukphy_detach), newbus attach/detach semantics (sys/kern/subr_bus.c:2100-2137), KASSERT gating (sys/sys/systm.h:94-122), and kernel configs (sys/config/X86_64_GENERIC).

The decisive chain of evidence

  1. ruephy_probe() at ruephy.c:96 gates attach on strcmp(device_get_name(parent), "rue") == 0, where parent is the grandparent of the miibus child (i.e. the USB NIC device).
  2. Exhaustive tree search (proof.sh section A-D) proves no driver named rue exists in this source tree: - no DRIVER_MODULE(rue, ...), no driver_t registering the name "rue" (the only two "rue" literals in sys/ are the probe gates themselves: sys/dev/netif/mii_layer/ruephy.c:96 and the orphaned sys/bus/u4b/net/ruephy.c:101); - no device rue in any kernel config or platform; - no if_rue*/rue.c source anywhere; - sys/bus/u4b/net/ β€” the USB NIC driver directory β€” contains ruephy.c/ruephyreg.h imported from FreeBSD but referenced by no build file (sys/conf/files, no u4b Makefile): never compiled. The RTL8150 NIC driver was simply never ported to DragonFly.
  3. The audited copy IS compiled (sys/conf/files:1094, dev/netif/mii_layer/ruephy.c optional miibus) and registers a driver on the miibus devclass β€” it probes every MII child and always returns ENXIO. Pure dead weight; zero attack surface.

Therefore the three latent patterns are unreachable: - empty-media branch ruephy.c:141-145 (DF-4930/DF-5001 family β€” panic via mii.c:228-245 ifmedia_set on empty list); - service-entry KASSERT ruephy.c:161 (DF-1973/DF-5009 family) β€” live on stock kernels because X86_64_GENERIC:56 enables INVARIANTS, but additionally defused by the instance!=0 refusal at ruephy.c:121-124 (a second ruephy can never attach to create the multi-PHY mismatch), and unreachable regardless; - unguarded mii->mii_media.ifm_cur->ifm_media deref ruephy.c:282 (NULL only via the empty-media path, which panics earlier at mediainit).

Other candidates considered and killed (negative result)

  • device_get_parent(device_get_parent(dev)) NULL deref in probe: miibus children are only created by an attached miibus whose own parent (the NIC) exists; not attacker-reachable.
  • ENXIO-at-ruephy.c:121-124 path after mii_softc_init leaving an unlinked, zeroed softc: newbus does NOT call device_detach after a failed attach (subr_bus.c:2115-2123 resets driver/state to DS_NOTPRESENT), so ukphy_detach's LIST_REMOVE (ukphy.c:178-186) cannot run on it.
  • ruephy_reset: mii_phy_reset (mii_physubr.c:183) is a bounded 100Γ—10ms poll; MIIF_NOISOLATE is honored (no BMCR_ISO write); the follow-up PHY_WRITE(BMCR_AUTOEN) is a 16-bit chip register write via the miibus method β€” chip-side only, no kernel memory involvement.
  • Status decode: double-read latch idiom on MSR is correct; ISO branch clears status; 10/100-only decode matches RTL8150 (no gigabit bits exist to miss).

Bottom line

The file is a provably-unreachable carrier of three already-filed family defects. The security-relevant finding is the unreachability itself: today's impact is none; the exposure is that any future port of rue(4) (FreeBSD if_rue.c) instantly activates (1) an INVARIANTS-live KASSERT and (2) the DF-4930 attach-panic leaf on stock kernels unless the DF-5001 hub guard lands with it. Recommended action: retire the file and the u4b orphans.

No guest was booted; nothing to reset. Fix validation not applicable (dead code; the "fix" is deletion, not a behavioral patch).

Fix status (batch validation)

Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.

(No fix.diff for this item: documented recommendation only - see Fix above.)

Fix verification

not_testable
baseline no→ patch + rebuild →patched clean

Not applicable: the finding is dead code whose remedy is deletion (or deferring to the DF-5001 family hub fix if rue(4) is ever ported). There is no baseline behavior to reproduce and no patch whose behavior change could be validated on the guest.

findings/poc/DF-5090/proof.log sections A-E establish that no rue parent driver exists, so no baseline or patched runtime behavior exists to compare.
per-fix-DF-5090

Confirmed kernel references

Detail

Evidence (decisive lines)

findings/poc/DF-5090/proof.log sections A-G: A shows the only "rue" literals in sys/ are the two ruephy probe gates themselves (mii_layer ruephy.c:96, u4b orphan ruephy.c:101); B/C no 'device rue' config and no if_rue/rue.c source; D u4b orphan referenced by no build file; E audited copy compiled via sys/conf/files:1094; F the three latent family patterns quoted from ruephy.c:141-145/161-162/282; G INVARIANTS enabled in stock X86_64_GENERIC (config line 56) so the KASSERT would be live if reachable.

PoC changes

Original evidence pack; no seed PoC existed. proof.sh was written fresh and iterated once (section G corrected: DragonFly stock X86_64_GENERIC DOES enable INVARIANTS β€” initial FreeBSD-centric annotation was wrong).

Verified recommended fix

Retire sys/dev/netif/mii_layer/ruephy.c (+ ruephyreg.h) and the never-compiled sys/bus/u4b/net/{ruephy.c,ruephyreg.h} orphans; if rue(4) is ever ported, land the DF-5001 miibus_mediainit guard in the same commit.

Verdict

Static-verification pass-2 audit of sys/dev/netif/mii_layer/ruephy.c: the driver is dead code. Its probe (ruephy.c:96) only accepts children of a NIC named "rue", and an exhaustive search of sys/ (proof.sh, all invariants green) shows no DRIVER_MODULE/driver_t/config/module/if_rue source named "rue" exists in this tree β€” sys/bus/u4b/net/ even holds a never-compiled FreeBSD ruephy.c orphan, confirming the RTL8150 NIC driver was never ported. The audited copy IS compiled into miibus (conf/files:1094) and registers a driver that probes every MII child and always returns ENXIO. Consequently the three latent family defects it carries β€” the DF-4930/DF-5001 empty-media attach-panic branch (ruephy.c:141-145), the DF-1973/DF-5009 service-entry KASSERT (ruephy.c:161, live on stock kernels since X86_64_GENERIC:56 enables INVARIANTS), and the unguarded ifm_cur deref (ruephy.c:282) β€” are unreachable on every kernel buildable from this tree. No runtime PoC is constructible (the required parent driver does not exist), so no guest run was performed; the tree/build-system proof is stronger than any single-guest observation. Impact today: none; the risk materializes only if rue(4) is ever ported without the DF-5001 hub guard.