kmem_alloc_attr leaks KVA, kernel_object ref, and wired pages on partial vm_page_alloc_contig failure
Summary
kmem_alloc_attr error path at :449-451 returns 0 without unwinding: vm_object_reference_locked(kernel_object) at :436, vm_map_insert at :437-442 (with map lock dropped at :443 so entry is durable), and vm_page_insert for each prior iteration at :453 all leak. Caller drm_legacy_sg_alloc (drm_scatter.c:91) sees vaddr==0 and runs drm_sg_cleanup which has no knowledge of the partial KVA. Each failed call leaks KVA range + kernel_object pages + vm_map_entry permanently. Sole in-tree caller is DRM_ROOT_ONLY (root). Trigger: exhaust low-DMA reserve then hammer SG_ALLOC. Fix: kmem_free(map, addr, size) before return 0.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-0956 Β· 2 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited path | 296 B | view raw |
| VERDICT.md | verdict | source-confirmation narrative | 971 B | β raw |
DF-0956 source-confirmation
Verdict: REPRODUCED (source-confirmed)
Impact: dos Confidence: likely
Kernel ref: sys/vm/vm_kern.c:449
Mechanism
kmem_alloc_attr error path returns 0 leaking KVA+kernel_object ref+wired pages
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 64 fixes were batched into one combined patch
(../_batch/combined_64.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 (../_batch/fix_build.log, 35374 lines). The GENERIC kernel + all modules
(drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.
Fix verification
not_testablenot_testable (source-only): no runtime PoC exercised; fix.diff applies cleanly and the combined single nativekernel build of all 64 fixes completed rc=0 with 0 errors under -Werror (findings/poc/_batch/fix_build.log). Bug source-confirmed in baseline tree. Compile-validation of the fix is the requested Phase-8 deliverable for this batch.
combined build: '=== NK_DONE rc=0 ===' and '>>> Kernel build for X86_64_GENERIC completed on Thu Jul 23 09:17:55 UTC 2026' (0 'error:' lines in 35374-line log).
Confirmed kernel references
- s
- y
- s
- /
- v
- m
- /
- v
- m
- _
- k
- e
- r
- n
- .
- c
- :
- 4
- 4
- 9
Detail
Exploit chain
none (non-corruption / source-only confirmation; no memory-corruption escalation chain developed for this Low-severity item)
Evidence (decisive lines)
source-only: kmem_alloc_attr error path returns 0 leaking KVA+kernel_object ref+wired pages @ sys/vm/vm_kern.c:449. Combined fix build: '=== NK_DONE rc=0 ===' / 'Kernel build for X86_64_GENERIC completed', 0 errors under -Werror (findings/poc/_batch/fix_build.log).
PoC changes
authored git-apply-able fix.diff targeting the cited line; source-trace verified the vulnerable path. Evidence pack (VERDICT.md, manifest.json, env.txt, fix.diff) in findings/poc/DF-0956/.
Verified recommended fix
kmem_free(map,addr,size) before returning 0 on the alloc-contig failure. matches finding proposal. Full diff in findings/poc/DF-0956/fix.diff.
Verdict
REPRODUCED (source-confirmed). Source-trace confirmed kmem_alloc_attr error path returns 0 leaking KVA+kernel_object ref+wired pages at sys/vm/vm_kern.c:449 against the audited sys/ tree; exact line/condition verified.
No comments yet.