sys/bus/u4b/net/ruephy.c is an unbuildable FreeBSD-API orphan β dead weight carrying latent ifm_cur derefs (:145/:231) and the DF-5001 empty-media branch
Summary
A FreeBSD-HEAD snapshot of the RTL8150 miibus PHY glue dropped in during the USB-stack import whose consumer rue(4) was never ported: referenced by no build target (the compiled ruephy is the DFly-native mii_layer twin, itself dormant per DF-5090) AND unbuildable (verbatim dies on the FreeBSD include layout; with includes granted onto DF's production headers it still fails on 8 distinct API symbols). 3-stage guest rig: control twin builds clean, orphan fails both stages. No runtime threat; residual risk is maintenance burn + a future mechanical wiring dragging in the unguarded ifm_cur derefs and the DF-5001 empty-media panic branch. Delete-the-orphan fix (git-apply-checked, removes ruephy.c + ruephyreg.h). NOTE: file is the RealTek RTL8150 glue, not Ralink/run(4) as seeded - audited as-is.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-5606 Β· 18 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | β | 3.1 KB | β raw | |
| VERDICT.md | β | 5.4 KB | β raw | |
| proof.sh | β | 3.3 KB | view raw | |
| proof.log | β | 1.8 KB | view raw | |
| setup.sh | β | 649 B | view raw | |
| build.sh | β | 171 B | view raw | |
| run.sh | β | 232 B | view raw | |
| rig_run.log | β | 1.9 KB | view raw | |
| build_s0.log | β | 6.0 KB | view raw | |
| build_s1.log | β | 6.1 KB | view raw | |
| build_s2.log | β | 10.6 KB | view raw | |
| env.txt | β | 518 B | view raw | |
| fix.diff | β | 7.9 KB | view raw | |
| stage0_control/Makefile | β | 134 B | β download | |
| stage1_verbatim/Makefile | β | 136 B | β download | |
| stage2_compatinc/Makefile | β | 1020 B | β download | |
| fakeinc/miidevs.h | β | 566 B | view raw | |
| verdict.json | β | 5.8 KB | view raw |
DF-5606 β sys/bus/u4b/net/ruephy.c is an unbuildable FreeBSD-API orphan
Severity: Info (dead code / maintenance hazard carrying latent family defects)
File: sys/bus/u4b/net/ruephy.c (232 LOC) + its header sys/bus/u4b/net/ruephyreg.h
What this is
A FreeBSD-HEAD snapshot of the RTL8150 internal-PHY miibus driver, dropped into
sys/bus/u4b/net/ (rue(4) glue that was never ported β there is no if_rue.c
anywhere in this tree). It is doubly dead:
- No build target references it. Not in
sys/conf/files, not insys/bus/u4b/net/MakefileSUBDIR (aue axe axge cdce cue ipheth kue mos udav uether urndis), not in any module Makefile. The ruephy that IS compiled is a different, DragonFly-native copy:sys/dev/netif/mii_layer/ruephy.c(sys/conf/files:1094) β itself dormant (DF-5090: no "rue" NIC exists). - It cannot compile against this tree. Its include layout
(
<dev/mii/mii.h>:47,<dev/usb/net/ruephyreg.h>:51) does not exist here, and even with the includes granted (mapped onto DragonFly's real production mii headers), the source references a different mii API generation:mii_phy_detach:62,MII_PHY_END:87,struct mii_phy_funcs:90,mii_phy_dev_probe:102,mii_phy_dev_attach+MIIF_NOMANPAUSE:110,mii_phy_setmedia:132,PHY_RESET/PHY_STATUS:163/:170, 1-argmii_phy_auto:164 β none exist or differ insys/dev/netif/mii_layer.
Why it matters
- Audit/review noise: it looks like reachable attack surface (it is not).
- Latent carriers: if it ever were revived together with the FreeBSD new-mii
core, it would reintroduce the family defects β the DF-5001 empty-media
attach-panic branch and the unguarded
ifm_curderefs atruephy.c:145(MII_TICK) andruephy.c:231(status decode when autoneg is off). - Its presence invites a bad copy-paste source for future u4b PHY glue.
Evidence in this pack
proof.sh/proof.logβ host-side static proof (build-target absence, include-layout absence, API-symbol absence, API-delta table with cites).build.sh/setup.shβ guest production-code KLD rig (3 stages):- S0 control: the production twin
mii_layer/ruephy.cbuilds cleanly through the same rig β rig is sound (build_s0.log). - S1 verbatim: the orphan dies at
ruephy.c:47:10: fatal error: dev/mii/mii.h(build_s1.log). - S2 includes granted: with
<dev/mii/*>/<dev/usb/net/ruephyreg.h>mapped onto DragonFly's unmodified production headers, the compile still fails on 8 distinct API symbols β gcc even suggests the DragonFly replacements ("did you mean 'mii_phy_set_media'?", β¦) (build_s2.log). rig_run.logβ the full rig console output (all checks green, exit 0).
Reproduce
In the guest (/root/df5606, populated by this pack):
sh setup.sh # verbatim copies from the guest's own /usr/src sh build.sh # S0 must build; S1/S2 must fail exactly as summarized
Host side, from the repo root:
sh findings/poc/DF-5606/proof.sh
Fix
Delete sys/bus/u4b/net/ruephy.c and sys/bus/u4b/net/ruephyreg.h
(fix.diff). Also called for by DF-5090's recommended fix for the twin.
VERDICT β DF-5606: sys/bus/u4b/net/ruephy.c is an unbuildable FreeBSD-API orphan
Bottom line: Not a memory-safety defect in itself. The file is a
FreeBSD-HEAD snapshot of the RTL8150 miibus PHY glue whose consumer (rue(4),
if_rue.c) was never ported to DragonFly; it is referenced by no build
target in the tree and cannot compile against DragonFly's mii API even
when deliberately wired up and granted its FreeBSD include layout. Every
latent defect it carries is therefore unreachable on any kernel buildable
from this tree. Removal is the fix; DF-5090 (filed on the compiled twin
sys/dev/netif/mii_layer/ruephy.c) already recommends deleting this pair.
Pass-2 analysis (family checklist)
(a) miibus methods β register reads, status decode, media tables
The only "device-supplied bits feeding indexes" surface would be
ruephy_status (ruephy.c:191-232): MSR/BMCR/BMSR bits (read twice and OR'd
β correct latched-bit idiom, :201/:212) are mapped to fixed IFM_*
constants (:220-229); no array index, no table lookup, no length. The only
table in the file, ruephys[] (:85-88), is properly terminated by
MII_PHY_END. ifm_cur->ifm_media at :231 is user-validated by the ifmedia
framework (SIOCSIFMEDIA), semantic-only. No OOB primitive exists here.
(b) ifmedia table construction
Not in this file β media entries are added by the mii core
(mii_phy_dev_attach(..., 1) in FreeBSD's API). The empty-capability edge
(BMSR_MEDIAMASK == 0 over USB β empty media list) is the DF-4930/DF-5001
family panic, owned by the hub finding.
(c) attach/detach vs miibus probing
No file-local softc state beyond struct mii_softc; attach is one core call
(:110-111), detach is core-provided (:62). The DF-5394-style probe/attach
race surface lives in the NIC-side plumbing (usb_ethernet.c:232
mii_phy_probe during ue_attach, :288-290 detach) β owned by the
DF-5493..5495 family. No file-local race. The probe gate
(:100-103: grandparent must be named "rue") additionally can never pass β no
such driver exists (DF-5090 proof, sections A-C).
(d) rue(4)-supplied data
PHY_READ results flow only into bit tests and the IFM decode above. The double-read at :153-154 handles latched-low link bits. Nothing feeds a length, index, or pointer.
Latent defects the orphan would carry if ever revived with the FreeBSD new-mii core
ruephy.c:145βIFM_SUBTYPE(ife->ifm_media)in MII_TICK withifm_curtaken at :118 unguarded (NULL only via the empty-media path that panics first in the family scenario).ruephy.c:231β same pattern in the non-autoneg status branch.- DF-5001 empty-media attach-panic branch via
mii_phy_dev_attach(..., 1).
Verification (Phase V) β production-code KLD rig on the guest
Guest: DragonFly 6.5-DEVELOPMENT #0 (X86_64_GENERIC, built Jul 2 2026), gcc
8.3 [DragonFly]. Guest /usr/src/sys/bus/u4b/net/ruephy.c md5-identical to
the audited repo file (83e5d308f4967b9d48494c1732aef59f), re-verified by
cksum inside the rig run.
- S0 control (
build_s0.log): the production twinsys/dev/netif/mii_layer/ruephy.c, copied verbatim, builds cleanly through the same KLD rig β the rig itself is sound. - S1 verbatim orphan (
build_s1.log): dies atruephy.c:47:10: fatal error: dev/mii/mii.h: No such file or directory(FreeBSD include layout;sys/dev/miiandsys/dev/usbdo not exist in DragonFly). - S2 includes granted (
build_s2.log): with<dev/mii/mii.h>,<dev/mii/miivar.h>,<dev/usb/net/ruephyreg.h>resolved to DragonFly's unmodified production headers (fakeinc, cksums inrig_run.log), the compile still fails on 8 distinct API symbols:mii_phy_detach:62,MII_PHY_END:87,struct mii_phy_funcs:90,mii_phy_dev_probe:102,mii_phy_dev_attach+MIIF_NOMANPAUSE:110,mii_phy_setmedia:132,PHY_RESET/PHY_STATUS:163/:170, 1-argmii_phy_auto:164. GCC's own suggestions spell out the generation gap ("did you mean 'mii_phy_set_media'?", "did you mean 'mii_phy_probe'?"). - Host static proof (
proof.log): zero build-target references; include layout absent; API symbols absent fromsys/dev/netif/mii_layer(only in-tree vestiges:atphy.c:89inside#if 0,atphy.c:99/:114comments).
Nothing was kldload'ed; /usr/src untouched; guest never panicked.
Attempts
- First rig run: stages mis-evaluated β my
-IrodeCFLAGS+=, whichsys/conf/kmod.mk:98rebuilds with a plain=(CFLAGS= ${COPTFLAGS} ${KCFLAGS} ${COPTS} ...), so the granted includes never reached cc, and the S1 grep pattern assumed gcc quote style while the actual message is clang/gcc-8 caret style. Control S0 already built OK. - Second rig run:
COPTS+= -I...(kmod.mk:108-109 preserves -I* past-nostdinc), grep patterns fixed β all three stages exactly as predicted, rig exit 0.
Fix
fix.diff deletes sys/bus/u4b/net/ruephy.c and
sys/bus/u4b/net/ruephyreg.h (git-apply-able, verified with
git apply --check). No runtime behavior changes: nothing references them.
Fix validation is not applicable β there is no baseline runtime behavior of
dead code to compare against.
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.
Fix verification
not_testableNot applicable: the finding is dead code whose remedy is deletion. There is no baseline runtime behavior (the file cannot compile or load on any kernel from this tree), so no baseline-vs-patched comparison exists; the deletion diff itself is verified with git apply --check.
findings/poc/DF-5606/fix.diff (deletes sys/bus/u4b/net/ruephy.c + ruephyreg.h; applies cleanly); rig_run.log S1/S2 show the file cannot reach a compiler pass, hence nothing observable changes post-fix.
Confirmed kernel references
- sys/bus/u4b/net/ruephy.c:47
- sys/bus/u4b/net/ruephy.c:51
- sys/bus/u4b/net/ruephy.c:62
- sys/bus/u4b/net/ruephy.c:87
- sys/bus/u4b/net/ruephy.c:90
- sys/bus/u4b/net/ruephy.c:100
- sys/bus/u4b/net/ruephy.c:102
- sys/bus/u4b/net/ruephy.c:110
- sys/bus/u4b/net/ruephy.c:132
- sys/bus/u4b/net/ruephy.c:145
- sys/bus/u4b/net/ruephy.c:164
- sys/bus/u4b/net/ruephy.c:231
- sys/bus/u4b/net/Makefile
- sys/conf/files:1094
- sys/dev/netif/mii_layer/miivar.h:260
- sys/dev/netif/mii_layer/miivar.h:270
- sys/dev/netif/mii_layer/miivar.h:276
- sys/dev/netif/mii_layer/atphy.c:89
- sys/bus/u4b/net/usb_ethernet.c:232
- sys/conf/kmod.mk:98
Detail
Evidence (decisive lines)
findings/poc/DF-5606/build_s2.log (gcc errors at ruephy.c:62/87/90/102/110/132/163/164/170 with 'did you mean mii_phy_set_media / mii_phy_probe' suggestions -- the API generation gap, compiler-attested); build_s1.log:63 (ruephy.c:47 fatal include error); build_s0.log (control twin builds, rig sound); rig_run.log (all rig checks green, cksums proving verbatim production sources, RIG VERDICT unbuildable); proof.log (host static proof A-D); fix.diff (verified git-apply-able deletion of the orphan pair).
PoC changes
No seed PoC existed (pass-2 finding authored with its own evidence). Rig iterated once: the granted-include -I originally rode CFLAGS+= which sys/conf/kmod.mk:98 wipes with a plain '=' assignment (rebuilt from COPTFLAGS/KCFLAGS/COPTS), so it never reached cc; moved to COPTS+= (kmod.mk:108-109 preserves -I* past -nostdinc) and relaxed the S1 expectation grep from gcc-quoted to the actual caret-style diagnostic.
Verified recommended fix
Delete the orphaned FreeBSD snapshot pair sys/bus/u4b/net/ruephy.c and sys/bus/u4b/net/ruephyreg.h (fix.diff); if rue(4)/new-mii is ever imported, land the DF-5001 miibus_mediainit guard in the same commit.
Verdict
Pass-2 audit of sys/bus/u4b/net/ruephy.c: the file is a FreeBSD-HEAD snapshot of the RTL8150 miibus PHY glue whose consumer rue(4) (if_rue.c) was never ported to DragonFly, and it is doubly dead. (1) No build target references it -- absent from sys/conf/files, from sys/bus/u4b/net/Makefile SUBDIR, and from every module Makefile (host proof.log section A); the ruephy that compiles is the DragonFly-native twin sys/dev/netif/mii_layer/ruephy.c (sys/conf/files:1094), itself dormant per DF-5090 (no NIC named 'rue' exists, so the orphan's probe gate at ruephy.c:100-103 can never pass either). (2) It cannot compile against this tree even when deliberately wired up: verbatim build dies at ruephy.c:47 'dev/mii/mii.h: No such file or directory' (FreeBSD include layout; S1), and with the includes granted -- mapped onto DragonFly's unmodified production mii headers -- the compile still fails on 8 distinct API symbols (S2: mii_phy_detach :62, MII_PHY_END :87, struct mii_phy_funcs :90, mii_phy_dev_probe :102, mii_phy_dev_attach + MIIF_NOMANPAUSE :110, mii_phy_setmedia :132, PHY_RESET/PHY_STATUS :163/:170, 1-arg mii_phy_auto :164), while the S0 control (the production twin through the identical rig) builds cleanly, proving the rig sound. The latent defects the orphan carries (unguarded ifm_cur derefs at :145/:231, the DF-5001 empty-media attach-panic branch) are therefore unreachable on every kernel buildable from this tree; they only revive if FreeBSD's whole new-mii core is imported alongside. No runtime manifestation exists to reproduce; the rig confirmed the dead-code disposition exactly as predicted.
No comments yet.