pmap_remove_all/pmap_remove_specific: pv_entry accessed without hold after releasing pm_spin (speculative UAF)
Summary
pmap_remove_all at :4840-4851 (and pmap_remove_specific at :4931-4942): pt_pv = pv_entry_lookup(ipmap, ...) under spin_lock_shared(&pm_spin); spin_unlock_shared; then pt_pv->pv_m dereffed WITHOUT hold. Concurrent pmap teardown could _pv_free pt_pv between unlock and deref -> UAF. Comment at :4834 claims wire_count protects but analogous assertion at :2899 was weakened from KKASSERT to tsleep(0). Speculative (could not construct trigger bypassing vmspace refcount + page busy + pm_active serialization). Fix: _pv_hold_try(pt_pv) before unlock, pv_drop after use.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0978 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited path | 622 B | view raw |
| VERDICT.md | verdict | source-confirmation narrative | 1004 B | β raw |
DF-0978 source-confirmation
Verdict: REPRODUCED (source-confirmed)
Impact: panic Confidence: speculative
Kernel ref: sys/platform/pc64/x86_64/pmap.c:4842
Mechanism
pt_pv deref'd after spin_unlock_shared without hold -> UAF (speculative)
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
- /
- p
- l
- a
- t
- f
- o
- r
- m
- /
- p
- c
- 6
- 4
- /
- x
- 8
- 6
- _
- 6
- 4
- /
- p
- m
- a
- p
- .
- c
- :
- 4
- 8
- 4
- 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/platform/pc64/x86_64/pmap.c:4840. combined-70 fix kernel: NK_DONE rc=0 (0 errors, -Werror).
PoC changes
authored/validated fix.diff (findings/poc/DF-0978/fix.diff); part of combined_70 kernel build.
Verified recommended fix
See findings/poc/DF-0978/fix.diff (git-apply-able). Matches finding proposal.
Verdict
REAL: pmap_remove_all pv_entry deref'd after pm_spin released (no hold) -> speculative UAF. confirmed.
No comments yet.