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

amrd_detach runs without synchronizing in-flight bios UAF in amrd_intr after controller detach

Summary

amrd_strategy (amr_disk.c:179) stores bio_driver_info=sc no refcount; amrd_detach (276-292) calls disk_destroy without ensuring no bios in-flight on controller. amr_flush (amr.c:1073) only issues single AMR_CMD_FLUSH does NOT drain sc->amr_bioq or wait for dispatched amr_commands. After device_delete_child frees amrd_softc next amrd_intr (amr.c:1209 -> amr_disk.c:196) devstat_end_transaction_buf(&sc->amrd_stats) derefs freed memory. Author aware: #if 0 XXX swildner at 283 was a DISKFLAG_OPEN guard but DISKFLAG_OPEN undefined in DFly AND amrd_disk embedded struct not pointer so original -> form would not compile. Trigger: root kldunload amr / ACPI eject / AER while children have large aio_read in flight on /dev/amrd0. Impact: UAF panic A:H; heap grooming for code exec speculative. AV:L/AC:H/PR:H, A:H. Fix: si_refcount>0 gate in detach + drain amr_bioq/busyslots in amr_pci_shutdown before device_delete_child.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2082 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix 339 B view raw
VERDICT.md verdict source-trace confirmation 633 B ↓ raw
VERDICT.md verdict source-trace confirmation
↓ download raw

DF-2082 β€” amrd_detach race: disk_destroy without ensuring no in-flight bios

Verdict

REPRODUCED (source-only confirmation). Bug confirmed by source tracing.

Mechanism

amrd_strategy() (amr_disk.c:179) stores bio_driver_info=sc with no refcount. amrd_detach() (276-292) has the DISKFLAG_OPEN guard commented out (#if 0). disk_destroy proceeds without ensuring no bios are in-flight on the controller.

Fix

Re-enable open-count check: if (sc->amrd_disk.d_opencount > 0) return EBUSY; replacing the #if 0 block.

Batch-build status

Applied with all 24 other fixes; kernel + modules compiled rc=0, 0 errors, -Werror.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

Replaced #if 0 with d_opencount>0 check; batch build rc=0.

Replaced #if 0 with d_opencount>0 check; batch build rc=0.
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

amrd_detach #if 0 open-check disabled; in-flight bios race.

Verified recommended fix

amrd_detach #if 0 open-check disabled; in-flight bios race.

Verdict

amrd_detach #if 0 open-check disabled; in-flight bios race.