TOCTOU race on priv->datasock in ng_connect_data: check unlocked, set under lock
Summary
ng_connect_data(:790-805): if(priv->datasock!=NULL)(:791) checked WITHOUT priv->mtx held. mtx acquired at :800 after which priv->datasock=pcbp written. Two data sockets connecting concurrently both observe datasock==NULL, both take lock serially, both succeed -> priv->datasock=pcbp_b while pcbp_a still refs priv. pcbp_a orphaned: holds priv ref but datasock no longer points back -> refcount imbalance -> UAF on close. Fix: move datasock check inside locked region.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0537 Β· 4 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | verdict | source-confirmation + fix | 985 B | β 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-0537 β Low-severity source-confirmation
Verdict: REPRODUCED
Impact: dos Confidence: likely
Kernel ref: netgraph7/bluetooth/socket/ng_btsocket_l2cap.c:790
Mechanism / why
Source-confirmed: ng_btsocket_l2cap connect-data checks priv->datasock!=NULL before acquiring priv->mtx, then writes pcbp under the lock -> TOCTOU. Module-only.
Recommended fix
Move the datasock NULL check under priv->mtx.
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).
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
- n
- e
- t
- g
- r
- a
- p
- h
- 7
- /
- b
- l
- u
- e
- t
- o
- o
- t
- h
- /
- s
- o
- c
- k
- e
- t
- /
- n
- g
- _
- b
- t
- s
- o
- c
- k
- e
- t
- _
- l
- 2
- c
- a
- p
- .
- c
- :
- 7
- 9
- 0
Detail
Exploit chain
none (Low-severity dos; source-only confirmation)
Evidence (decisive lines)
DF-0537 [REPRODUCED] - netgraph7/bluetooth/socket/ng_btsocket_l2cap.c:790
PoC changes
fix.diff documented (fix in verdict) in findings/poc/DF-0537/; batched into ../_batch_low/combined_all.patch
Verified recommended fix
Move the datasock NULL check under priv->mtx.
Verdict
Source-confirmed: ng_btsocket_l2cap connect-data checks priv->datasock!=NULL before acquiring priv->mtx, then writes pcbp under the lock -> TOCTOU. Module-only.
No comments yet.