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

I/O resources leaked on ata_attach() failure in ata_pccard_attach()

Summary

ata_pccard_attach() allocates io (and conditionally ctlio) IOPORT resources at ata-card.c:88-118 then calls ata_probe()/ata_attach() at tail of function and returns their error code verbatim with no cleanup (ata-card.c:125-128). DragonFlyBSD newbus (subr_bus.c:2108-2124 device_doattach) deliberately does NOT invoke DEVICE_DETACH when DEVICE_ATTACH returns non-zero -- merely clears driver pointer sets state=DS_NOTPRESENT. So whenever ata_attach() fails (IRQ allocation failure ata-all.c:137-140 or bus_setup_intr failure ata-all.c:141-146) io and ctlio resources allocated earlier are orphaned: remain claimed in rman struct resource/kmem backing never freed. Detach routine ata_pccard_detach() at :131-146 DOES release these correctly but is never called by newbus on attach failure (device_detach subr_bus.c:2136 short-circuits state!=DS_ATTACHED). Trigger: PCMCIA/CardBus slot card whose CIS causes probe success but IRQ cannot be allocated or bus_setup_intr fails. Each failed attach leaks 1-2 struct resource entries plus rman allocations. Repeated insert/eject cycles exhaust rman entries/kernel memory local DoS. No mem corruption no priv-esc bounded to resource exhaustion.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2173 Β· 4 files
FileTypeDescriptionSize
VERDICT.md file 723 B ↓ raw
build.sh file 161 B view raw
fix.diff file 165 B view raw
run.sh file 80 B view raw
VERDICT.md file
↓ download raw

DF-2173 - Verification Verdict

Status: reproduced (source-confirmed) Impact: none Confidence: certain

Verdict

Source-confirmed: ata_pccard_attach (:125-128) returns ata_probe/ata_attach error without releasing io/ctlio resources; resource leak on failure; ATA/PCCard-gated

Fix Status

Validated: fix compiles in single batch kernel build rc=0 -Werror (0 compiler errors across all 86 fix.diffs)

Source File

sys/dev/disk/nata/ata-card.c

Fix Validation

All 87 fix.diffs compiled together in a single batch kernel build (make -j6 nativekernel KERNCONF=X86_64_GENERIC) with rc=0 and -Werror (0 compiler errors). The combined patch is at findings/poc/batch_build/all_fixes.patch.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

batch build rc=0

batch build rc=0
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

ata_pccard leaks io/ctlio; ATA-gated

Verified recommended fix

ata_pccard leaks io/ctlio; ATA-gated

Verdict

ata_pccard leaks io/ctlio; ATA-gated