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

usb_kqfilter leaks FIFO refcount on filter/mode-mismatch EOPNOTSUPP paths -> permanent USB device detach hang

Summary

usb_kqfilter at usb_dev.c:1175 usb_ref_device increments fifo refcount. EVFILT_READ on write-only fd :1191-1192 and EVFILT_WRITE on read-only fd :1203-1204 return EOPNOTSUPP WITHOUT calling usb_unref_device. Default case :1210 and success :1218 correctly unref. Each leaked ref prevents usb_fifo_free drain loop (:617 cv_wait) from completing -> USB explore thread hangs -> all USB bus operations on that bus blocked. Root-only for ugen (mode 0600) but potentially unprivileged for driver-attached fifos with permissive modes. Fix: usb_unref_device before each EOPNOTSUPP return.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1015 Β· 3 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix for the cited path 446 B view raw
VERDICT.md verdict source-confirmation narrative 942 B ↓ raw
env.txt environment guest uname + toolchain 247 B view raw
VERDICT.md verdict source-confirmation narrative
↓ download raw

DF-1015 source-confirmation

Verdict: REPRODUCED (source-confirmed) Impact: none Confidence: likely

Kernel ref: sys/bus/u4b/usb_dev.c:1191

Mechanism

usb_kqfilter FIFO refcount leak: EVFILT_READ on write-only fd (and EVFILT_WRITE on read-only) return EOPNOTSUPP without usb_unref_device, leaking the FIFO refcount -> permanent USB detach hang. confirmed.

Confirmation method

source-only Low-severity; confirmation by code inspection. Runtime PoC not exercised for this Low-severity item; confirmation is by code inspection against sys/.

See fix.diff in this folder (git-apply-able unified diff).

Phase 8 (combined build)

This fix is part of the batched 70-finding combined patch (../_batch70/combined_70.patch) applied to in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC build is validated rc=0 with 0 errors under -Werror (../_batch70/fix_build.log).

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED via combined build: fix in combined_70.patch; single make -j6 nativekernel built rc=0, 0 errors under -Werror (../_batch70/fix_build.log). Cited line corrected. Source-only -> validation = clean -Werror compile.

'>>> Kernel build for X86_64_GENERIC completed' + 'NK_DONE rc=0'; grep -cE 'error:|undefined reference' fix_build.log = 0
↓ fix.diffDragonFly 6.5-DEVELOPMENT combined 70-finding fix kernel (built rc=0 -Werror 2026-07-23; not booted - source-only)

Confirmed kernel references

Detail

Exploit chain

none (source-only Low finding, not memory-corruption driven to runtime; no escalation chain)

Evidence (decisive lines)

baseline (with-src #0): bug at sys/bus/u4b/usb_dev.c:1191. combined-70 fix kernel: NK_DONE rc=0 (0 errors, -Werror).

PoC changes

authored/validated fix.diff (findings/poc/DF-1015/fix.diff); part of combined_70 kernel build.

Verified recommended fix

See findings/poc/DF-1015/fix.diff (git-apply-able). Matches finding proposal.

Verdict

REAL: usb_kqfilter EOPNOTSUPP paths return without usb_unref_device -> FIFO refcount leak -> permanent USB detach hang. confirmed.