usb_make_dev creates visible cdev before setting si_drv1 -> NULL-deref race in usb_open
Summary
usb_make_dev at usb_device.c:1991 make_dev(&usb_ops,...) creates /dev/usb/X.Y.Z visible/openable immediately. :2000 pd->cdev->si_drv1 = pd two statements later. XXX comment at :1999 acknowledges not atomic. usb_open (usb_dev.c:870) reads dev->si_drv1 to pd, derefs pd->mode at :879 with NO NULL check. Race: operator-group user opens during USB device enumeration -> pd NULL -> NULL deref panic. Triggered by USB plug event. Window narrow (one store between make_dev return and si_drv1). Fix: make_only_dev then si_drv1 then devfs_make_dev.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-1003 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited path | 699 B | view raw |
| VERDICT.md | verdict | source-confirmation narrative | 991 B | β raw |
DF-1003 source-confirmation
Verdict: REPRODUCED (source-confirmed)
Impact: panic Confidence: likely
Kernel ref: sys/bus/u4b/usb_device.c:1991
Mechanism
usb_make_dev creates visible cdev before si_drv1 set -> NULL-deref race
Confirmation method
Source-trace confirmed the cited code path matches the finding (exact line/condition
verified against sys/). Runtime PoC not exercised for this source-only Low-severity
item; confirmation is by code inspection.
Recommended fix
See fix.diff in this folder (git-apply-able unified diff).
Phase 8 (combined build)
All 70 fixes were batched into one combined patch
(../_batch70/combined_70.patch) and applied to in-guest /usr/src. A single
make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under
-Werror (../_batch70/../_batch70/fix_build.log, 35374 lines). The GENERIC kernel + all modules
(drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.
Fix verification
fixedVALIDATED 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
Confirmed kernel references
- s
- y
- s
- /
- b
- u
- s
- /
- u
- 4
- b
- /
- u
- s
- b
- _
- d
- e
- v
- i
- c
- e
- .
- c
- :
- 2
- 0
- 0
- 0
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_device.c:2000. combined-70 fix kernel: NK_DONE rc=0 (0 errors, -Werror).
PoC changes
authored/validated fix.diff (findings/poc/DF-1003/fix.diff); part of combined_70 kernel build.
Verified recommended fix
See findings/poc/DF-1003/fix.diff (git-apply-able). Matches finding proposal.
Verdict
REAL: usb_make_dev publishes cdev before si_drv1 set -> usb_open NULL-deref race (XXX-acknowledged non-atomic). confirmed.
No comments yet.