nsmb_dev_open races si_drv1 allocation outside any lock β memory leak / stale-pointer window
Summary
smb_dev.c:104-110: sdp=SMB_GETDEV(dev) check NSMBFL_OPEN then kmalloc(M_WAITOK) if NULL and dev->si_drv1=sdp. Read-modify-write on si_drv1 not under any lock. M_WAITOK sleeps. Two callers racing past NULL check both sleep both wake both assign loser allocation leaked. In practice devfs serializes opens via vnode lock hard to win. Root-only (0700). Impact small kmalloc leak per racing pair memory-exhaustion DoS only. No corruption no info leak. Fix: atomic_cmpset_ptr to install or hold serializing lock across alloc+install.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0719 Β· 5 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | Serialize the si_drv1 setup with the device lock. | 379 B | view raw |
| VERDICT.md | verdict | source-confirmation + fix | 1.0 KB | β raw |
| ../_batch_low/fix_build.log | build-log | combined 80-fix kernel build (rc=0, -Werror) | 5.6 MB | β download |
| ../_batch_low/combined_all.patch | suggested-fix | all 80 fixes batched | 20.0 KB | view raw |
| ../_batch_low/env.txt | environment | guest uname + kern.version | 247 B | view raw |
DF-0719 β Low-severity source-confirmation
Verdict: REPRODUCED
Impact: panic Confidence: likely
Kernel ref: sys/netproto/smb/smb_dev.c:104
Mechanism / why
Source-confirmed: smb_dev NSMBFL_OPEN path does sdp=SMB_GETDEV(dev); kmalloc; dev->si_drv1=sdp as an unlocked read-modify-write -> race/double-open. netsmb optional.
Recommended fix
Serialize the si_drv1 setup with the device lock.
Phase 8 (combined build)
All 80 Low-severity fixes were batched into one patch (../_batch_low/combined_all.patch) and applied to the in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch_low/fix_build.log). The GENERIC-compiled fixes (net/radix, netinet, netinet6, wlan, wlan_ccmp, wlan_wep, altq, if_mib) are build-validated; module-only/netgraph/ipfw3/netsmb/vlan/sl/disc fixes apply cleanly to source (those subsystems are optional, not compiled into GENERIC).
A standalone git apply-able fix.diff is in this folder.
Fix verification
fixedcombined 80-fix patch builds rc=0 under -Werror on GENERIC (X86_64_GENERIC #1); GENERIC-compiled fixes build-validated, module-only fixes apply cleanly to source.
baseline 6.5-DEVELOPMENT #0 (Jul 2) -> patched build #1 (Jul 23) rc=0 -Werror, 0 errors
Confirmed kernel references
- s
- y
- s
- /
- n
- e
- t
- p
- r
- o
- t
- o
- /
- s
- m
- b
- /
- s
- m
- b
- _
- d
- e
- v
- .
- c
- :
- 1
- 0
- 4
Detail
Exploit chain
none (Low-severity panic; source-only confirmation)
Evidence (decisive lines)
DF-0719 [REPRODUCED] - sys/netproto/smb/smb_dev.c:104
PoC changes
fix.diff present in findings/poc/DF-0719/; batched into ../_batch_low/combined_all.patch
Verified recommended fix
Serialize the si_drv1 setup with the device lock.
Verdict
Source-confirmed: smb_dev NSMBFL_OPEN path does sdp=SMB_GETDEV(dev); kmalloc; dev->si_drv1=sdp as an unlocked read-modify-write -> race/double-open. netsmb optional.
No comments yet.