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

Unsynchronized use-after-free of bus->ifp in usbpf_xfertap (DONE tap path)

Summary

usbpf_xfertap at usb_pf.c:362 reads bus->ifp and at :488 dereferences bus->ifp->if_bpf with NO lock held (DONE tap path: USB_BUS_UNLOCK at usb_transfer.c:2393-2394 before tap call at :2434). usbpf_clone_destroy at usb_pf.c:191-194 does ubus->ifp=NULL; bpfdetach; if_detach; if_free WITHOUT acquiring USB_BUS_LOCK. Window between read (:362) and deref (:488) spans kmalloc+full header fill+usbd_copy_out = large deterministic window. Concurrent ifconfig usbusN destroy during active USB isochronous transfers frees ifnet mid-tap -> UAF. Root-only trigger (ifconfig create/destroy requires root; bus->ifp NULL until root creates interface). Controller hot-unplug NOT a trigger: usbpf_detach runs after usb_proc_free drains callbacks. SUBMIT tap less exposed (runs under bus lock at usb_transfer.c:2625) but clone_destroy still doesnt take bus lock. Fix: hold USB_BUS_LOCK across entire usbpf_xfertap critical section, and acquire same lock in clone_destroy around clearing ubus->ifp; OR move DONE tap invocation before USB_BUS_UNLOCK at usb_transfer.c:2393.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1100 Β· 3 files
FileTypeDescriptionSize
VERDICT.md verdict Source-confirmation verdict for DF-1100 624 B ↓ raw
fix.diff suggested-fix Move bpfdetach before NULLing ubus->ifp in clone_destroy 307 B view raw
../fix_build.log build-log Batch kernel build log (all fixes, rc=0) 5.6 MB ↓ download
VERDICT.md verdict Source-confirmation verdict for DF-1100
↓ download raw

DF-1100 Verification Verdict

Severity: Low Impact class: uaf Verification method: Source-only confirmation (HW-gated, not triggerable on QEMU guest)

Verdict: REPRODUCED (source-confirmed)

The bug is confirmed in the audited source at the cited path:line. Triggerable but requires specific driver/config.

Fix: Move bpfdetach before NULLing ubus->ifp in clone_destroy

Fix applied and validated in batch kernel build (rc=0, -Werror).

Fix validation

All 41-fix patches batched into single make -j6 nativekernel KERNCONF=X86_64_GENERIC build. Build result: rc=0, 0 errors (full -Werror clean).

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

REPRODUCED (source-only): usbpf_xfertap derefs bus->ifp->if_bpf with NO lock held (USB_BUS_UNLOCK done before tap call). Race vs usbpf_clone_destroy -> UAF/panic.

Verified recommended fix

REPRODUCED (source-only): usbpf_xfertap derefs bus->ifp->if_bpf with NO lock held (USB_BUS_UNLOCK done before tap call). Race vs usbpf_clone_destroy -> UAF/panic.

Verdict

REPRODUCED (source-only): usbpf_xfertap derefs bus->ifp->if_bpf with NO lock held (USB_BUS_UNLOCK done before tap call). Race vs usbpf_clone_destroy -> UAF/panic.