mlx_start() controller-wedge path leaks mlx_busycmds (slot never decremented) -> permanent EBUSY lockout of all controller I/O; WEDGED command's DMA map left loaded
Summary
When the controller refuses all mailbox writes, the error path clears the slot without mlx_busycmds--; the only decrement is in mlx_done, unreachable for a command the controller never took. After a few wedge events mlx_getslot returns EBUSY permanently - every read/write/ioctl on the controller fails until reboot. Secondary: the WEDGED command never enters mlx_work, so mlx_complete never unmaps it and it is recycled with mc_data still bus_dmamap_load()ed. Wedged DAC960 converts into permanent unrecoverable I/O lockout. Decrement-on-error fix.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-3951 Β· 9 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | doc | bug + reachability + fix | 2.1 KB | β raw |
| VERDICT.md | verdict | source proof | 2.0 KB | β raw |
| mlx_ioctl_trigger.c | trigger | wedge mode: busycmds leak -> permanent EBUSY | 4.6 KB | view raw |
| build.sh | script | build | 108 B | view raw |
| run.sh | script | run | 116 B | view raw |
| build.log | log | guest compile | 356 B | view raw |
| run.log | log | guest run (ENOENT, no HBA) | 217 B | view raw |
| env.txt | env | guest uname | 185 B | view raw |
| fix.diff | suggested-fix | see README | 689 B | view raw |
DF-3951 β mlx_start() wedge path leaks mlx_busycmds (slot-count never decremented) and leaves the DMA map loaded
Severity: Low Β· CWE-772 / resource-accounting Β· hardware-gated (controller must stop accepting mailbox writes)
Bug
When the controller refuses every mailbox write (the 100000-iteration spin
at mlx.c:2089-2097 fails), mlx_start() revokes the slot on the error path:
sc->mlx_busycmd[mc->mc_slot] = NULL; /* mlx.c:2107 */
device_printf(sc->mlx_dev, "controller wedged (not taking commands)\n");
mc->mc_status = MLX_STATUS_WEDGED;
but forgets sc->mlx_busycmds--. The only decrement in the driver is in
mlx_done() (mlx.c:2146), which only runs for commands the controller
completed. Each wedged submission therefore permanently inflates
mlx_busycmds:
mlx_getslot()(mlx.c:1966) refuses new commands oncemlx_busycmds >= limit - 4(normal) />= limit(priority) β after a handful of wedge events all future I/O returns EBUSY forever:mlx_startio()breaks out (mlx.c:1739-1742), every read/write to the mlx drives fails, and even MLX_COMMAND management ioctls are locked out. No recovery path exists short of a reboot.
Additionally, on the mlx_startio() wedge path the command's DMA map is
never unloaded: mlx_unmapcmd() is only called from mlx_complete()
(mlx.c:2194) for commands that reached the work queue; the WEDGED command
never did, and mlx_completeio() (mlx.c:1796-1800 β 1839) releases the
command with mc->mc_data still mapped. The recycled command's map is then
re-loaded by a later mlx_mapcmd() without an intervening unload.
Build / Run / Expected
cc -O2 -Wall -o mlx_ioctl_trigger mlx_ioctl_trigger.c
./mlx_ioctl_trigger wedge /dev/mlx0 # against a controller that stopped taking commands
dd if=/dev/mlxd0 of=/dev/null bs=64k count=1 # -> EBUSY permanently
Expected on hardware: after N wedge events, dd fails and all mlx I/O
returns EBUSY until reboot. On this guest: ENOENT (no HBA) β hardware-gated.
Fix
Decrement mlx_busycmds alongside the slot clear (fix.diff).
DF-3951 β Verification Verdict
Status: inconclusive (hardware-gated; source-certain) Impact demonstrated: none (expected: permanent EBUSY lockout of all controller I/O) Confidence: certain (source), runtime untestable (no DAC960 HBA)
Source proof
mlx_getslot()incrementssc->mlx_busycmdswhen handing out a slot βsys/dev/raid/mlx/mlx.c:1981-1982.- Sole decrement:
mlx_done()atmlx.c:2145-2146, reachable only via a completion posted bymlx_findcomplete()(mlx.c:2137). - Wedge path:
mlx_start()atmlx.c:2107clearssc->mlx_busycmd[slot]without touchingmlx_busycmds(grep-verified: no other decrement in the driver). Consequence:mlx_getslot()atmlx.c:1966permanently fails once the leaked count reacheslimit - 4; every subsequentmlx_startio()breaks atmlx.c:1739-1742β all disk I/O EBUSY, no recovery until reboot. - Secondary defect on the same path: the WEDGED command never enters
sc->mlx_work(TAILQ_INSERT only on queue success, mlx.c:2094), somlx_complete()(mlx.c:2194) never callsmlx_unmapcmd()for it;mlx_startio()'s wedge handler (mlx.c:1798-1799) callsmlx_completeio()directly β command recycled (mlx.c:1839) withmc->mc_datastill bus_dmamap_load()ed (mlx_mapcmd, mlx.c:2038).
Impact: permanent controller I/O lockout (availability) β operator/root gated ioctls or ordinary I/O against a wedged HBA; no memory-safety impact.
Guest result
Trigger compile-tested (BUILD_RC=0, DragonFly 6.5-DEVELOPMENT); runtime ENOENT β no Mylex hardware. Honest: inconclusive / source-certain.
Fix validation
fix.diff adds the missing decrement. Not runtime-testable here β fix_status: not_testable.
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_testable: no Mylex hardware in guest
fix.diff
Confirmed kernel references
Detail
Exploit chain
wedged controller -> N failed submissions leak busycmds -> permanent EBUSY lockout of all mlx I/O (reboot required)
Evidence (decisive lines)
VERDICT.md cites mlx.c:1981-1982,2107,2146,1966,1739-1742,1796-1800; mlx_ioctl_trigger.c (wedge mode); build.log/run.log; fix.diff decrement
PoC changes
no seed; self-contained trigger
Verified recommended fix
sc->mlx_busycmds-- next to the mlx_busycmd[slot]=NULL clear on the wedge path.
Verdict
Source-certain accounting leak: mlx_start's controller-wedge path clears mlx_busycmd[mc_slot] (mlx.c:2107) without mlx_busycmds-- (the only decrement is in mlx_done, mlx.c:2146, unreachable for a command the controller never accepted). After a few wedge events mlx_getslot (mlx.c:1966) returns EBUSY permanently -> all disk I/O and management ioctls on the controller fail until reboot. Secondary: the WEDGED command's dmamap is never unloaded (mlx_unmapcmd only from mlx_complete for queued commands; startio wedge path calls mlx_completeio directly, mlx.c:1796-1800). Runtime inconclusive: no HBA in guest.
No comments yet.