truephy_attach 'no media present' branch skips mii_phy_add_media, so miibus_mediainit calls ifmedia_set on an EMPTY media list β panic("ifmedia_set") at attach (4th leaf of the DF-4930/DF-4957/DF-4981 family)
Summary
The 4th and final leaf (completes the mii family): the no-media branch adds nothing yet still invokes the hub whose unguarded ifmedia_set panics. Sink proven live by DF-5001's replay; end-to-end needs ET1011 hw. NOTE: truephy sets MIIF_NOISOLATE so the DF-4930 unconditional-add leaf fix is a no-op here - the DF-5001 hub guard or an explicit ifmedia_add (leaf fix authored) is required.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-5003 Β· 5 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | β | 905 B | view raw | |
| fixcheck-build.log | β | 930 B | view raw | |
| verdict.json | β | 4.3 KB | view raw | |
| VERDICT.md | β | 2.9 KB | β raw | |
| README.md | β | 2.4 KB | β raw |
DF-5003 β truephy_attach "no media present" branch skips all media setup β
miibus_mediainit panics on the empty list (4th instance of the DF-4930 family)
What
truephy_attach() has the standard family shape (truephy.c:170-176):
if ((sc->mii_capabilities & BMSR_MEDIAMASK) == 0 &&
(sc->mii_extcapabilities & EXTSR_MEDIAMASK) == 0)
kprintf("no media present"); /* <-- adds NO media */
else
mii_phy_add_media(sc);
...
MIIBUS_MEDIAINIT(sc->mii_dev); /* truephy.c:178 */
When the ET1011/ET1011C's BMSR reports no media bits and EXTSR reports no
extended media (faulty or malicious PHY-in-the-loop), no media entry is
ever added; MIIBUS_MEDIAINIT dispatches to miibus_mediainit()
(mii.c:227-245), whose terminal ifmedia_set(&mii->mii_media, 0)
panics β panic("ifmedia_set") (sys/net/if_media.c:174). Same sink as
DF-4930 (atphy), DF-4957 (ciphy), DF-4981 (jmphy) β proven live on this
kernel by the DF-5001 hub replay (../DF-5001/panic.txt: the walk from
mii.c:238-244 on an empty list β panic: ifmedia_set, guest down).
truephy-specific pass-2 note: the family leaf-fix pattern from
DF-4930 ("just call mii_phy_add_media() unconditionally") does NOT work
here β truephy always sets MIIF_NOISOLATE (truephy.c:157) and
mii_phy_add_media()'s IFM_NONE fallback is gated on MIIF_NOISOLATE
being CLEAR (mii_physubr.c:230-232), so an unconditional call still adds
nothing. The working fixes are (a) the hub fix (DF-5001, recommended β
covers the whole family) or (b) an explicit ifmedia_add in the
no-media branch (fix.diff here, mirroring DF-4957's ciphy fix).
Reproduce
The sink is already proven on the guest kernel by the DF-5001 pack
(../DF-5001/: baseline hw.miihub_fire=1 β panic + guest down;
hw.miihub_fixcheck=1 β fixed walk survives). What cannot be exercised
on this guest is the entry into the branch: it requires an Agere
ET1011/ET1011C PHY (MII_PHYDESC(AGERE, ET1011/ET1011C), truephy.c:69-73)
whose ID registers match but whose BMSR/EXTSR media bits read zero β PHY
register behavior is not emulatable in QEMU. Hence not_reproduced
end-to-end (same classification as DF-4930/4957/4981).
Fix
Primary: the DF-5001 hub fix (miibus_mediainit empty-list guard) β one
change covers every family member including this one. Leaf parity:
fix.diff (explicit IFM_NONE fallback via ifmedia_add; applies cleanly;
compiles under -Werror as a KLD source on the guest β fixcheck-build.log).
DF-5003 VERDICT β NOT REPRODUCED end-to-end (hardware precondition);
code path certain; sink proven live by the DF-5001 hub replay
Bottom line: truephy_attach()'s "no media present" branch
(truephy.c:171-175) adds no media entry, yet attach still terminates in
MIIBUS_MEDIAINIT(sc->mii_dev) (truephy.c:178) β miibus_mediainit()
(mii.c:227-245) β ifmedia_set(&mii->mii_media, 0) (mii.c:244) β
panic("ifmedia_set") (sys/net/if_media.c:174). This is the fourth
instance of the DF-4930/DF-4957/DF-4981 family, and the sink itself has
now been executed live on this exact kernel by the DF-5001 hub replay
(../DF-5001/panic.txt: ifmedia_set: no match for 0x0/0xfffffff β
panic: ifmedia_set, trace ifmedia_set<-miihub_fire<-sysctl, guest
down; the fixed walk survives in ../DF-5001/run.2.log).
Why not_reproduced (consistent with the family)
Entering the branch requires an Agere ET1011/ET1011C PHY whose ID
registers match the truephy table (truephy.c:69-73) while BMSR reports
BMSR_MEDIAMASK == 0 and EXTSR EXTSR_MEDIAMASK == 0 β a faulty or
malicious PHY-in-the-loop. The QEMU guest has no such PHY and MDIO
register behavior is not emulatable, so the end-to-end chain cannot run
here (identical classification to DF-4930/DF-4957/DF-4981: Low,
hardware-fault precondition, attach-time DoS, no unprivileged trigger).
Pass-2 deltas vs. the sibling findings
- The DF-4930 leaf-fix pattern is a no-op for this driver.
truephy.c:157 sets
MIIF_NOISOLATEbefore the media branch, andmii_phy_add_media()'s IFM_NONE fallback is gated on MIIF_NOISOLATE being clear (mii_physubr.c:230-232) β an unconditionalmii_phy_add_media()would still add zero entries and the panic would remain. The correct fixes are the hub guard (DF-5001, primary) or an explicitifmedia_add(this pack's fix.diff, mirroring DF-4957's ciphy fix which had the same constraint). - Multiphy ordering note: with several PHYs on the bus, the FIRST
attaching PHY drives
miibus_mediainit(each PHY attach ends in MIIBUS_MEDIAINIT); a zero-cap truephy first in the list panics before later PHYs can add media β the hub guard also fixes that ordering window.
Fix
fix.diff β explicit ifmedia_add(&mii->mii_media,
IFM_MAKEWORD(IFM_ETHER, IFM_NONE, 0, sc->mii_inst), MII_MEDIA_NONE,
NULL) inside the no-media branch. Applies cleanly
(git apply --check OK); the patched truephy.c compiles clean under the
kernel's full -Werror set as a KLD source on the guest
(fixcheck-build.log). The DF-5001 hub fix is the recommended family
fix and covers this driver without any truephy change.
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_testableLeaf fix.diff (explicit ifmedia_add(IFM_NONE) in the no-media branch) applies cleanly and compiles under -Werror as a KLD source on the guest (fixcheck-build.log); its operative mechanism (fallback entry present -> ifmedia_set matches -> no panic, ifm_cur non-NULL) is validated live by the DF-5001 fixcheck replay. End-to-end exercise requires ET1011 hardware (absent). The DF-5001 hub fix is the recommended family fix and also covers this driver unchanged.
fixcheck-build.log (truephyfix.ko linked from patched truephy.c), ../DF-5001/run.2.log (fixcheck survived), fix.diff (git apply --check OK)
Confirmed kernel references
Detail
Evidence (decisive lines)
../DF-5001/panic.txt (sink panic executed on this kernel: 'ifmedia_set: no match for 0x0/0xfffffff' -> panic, trace ifmedia_set<-miihub_fire<-sysctl_root<-userland_sysctl<-sys___sysctl, guest down), ../DF-5001/run.2.log (fixed walk survives, ifm_cur non-NULL), ../DF-5001/miihub.c (verbatim hub-walk replay), fixcheck-build.log (patched truephy.c compiles under -Werror as KLD source), fix.diff (git apply --check OK), VERDICT.md (full trace truephy.c:163-178 -> mii.c:227-245 -> sys/net/if_media.c:174)
PoC changes
No new runtime PoC: the sink replay is shared with the DF-5001 hub pack (same terminal path); a truephy-specific replay would only re-execute identical ifmedia statements. Leaf fix authored in the explicit-ifmedia_add style because the mii_phy_add_media fallback is MIIF_NOISOLATE-gated for this driver.
Verified recommended fix
Apply the DF-5001 hub fix (miibus_mediainit empty-list guard); optionally the leaf fix.diff (explicit IFM_NONE ifmedia_add) for parity with DF-4957.
Verdict
NOT REPRODUCED end-to-end: entering truephy_attach's 'no media present' branch (truephy.c:171-175) requires an Agere ET1011/ET1011C PHY whose ID registers match (truephy.c:69-73) while BMSR/EXTSR media capability bits read zero -- faulty or malicious hardware-in-the-loop, not emulatable on the QEMU guest (same classification as family siblings DF-4930/DF-4957/DF-4981). The kernel-side sink of the chain is now PROVEN live on this exact kernel by the DF-5001 hub replay: the miibus_mediainit walk (mii.c:238-244) on an EMPTY list -- exactly what truephy.c:171-175+178 leads to -- yields panic("ifmedia_set") with trace ifmedia_set<-miihub_fire<-sysctl and kills the guest (../DF-5001/panic.txt), and the fixed walk survives with ifm_cur non-NULL (../DF-5001/run.2.log). Pass-2 deltas: (1) the DF-4930 leaf-fix pattern ('call mii_phy_add_media unconditionally') is a NO-OP for truephy because truephy.c:157 sets MIIF_NOISOLATE and mii_phy_add_media's IFM_NONE fallback is gated on MIIF_NOISOLATE being clear (mii_physubr.c:230-232) -- the working fixes are the DF-5001 hub guard (primary) or an explicit ifmedia_add (this pack's fix.diff, like DF-4957's ciphy fix); (2) as the FIRST-attaching PHY on a multi-PHY bus, a zero-cap truephy panics the walk before later PHYs add their media -- also covered by the hub guard. Severity Low: attach-time DoS, hardware-fault precondition, no unprivileged userland trigger, no memory unsafety.
No comments yet.