β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-0957

kmem_alloc3/kmem_alloc_attr ignore vm_map_insert return; round_page() overflow to size=0 yields bogus non-zero addr

Summary

kmem_alloc3 (:219) and kmem_alloc_attr (:425) do size=round_page(size) which wraps to 0 for x in top PAGE_MASK bytes of ulong range. No size==0 check. vm_map_findspace(length=0) succeeds with addr=first free KVA. vm_map_insert rejects start>=end at vm_map.c:1275-1278 -> inserts nothing -> return discarded at :253/:437. Function returns non-zero addr to caller (dangling pointer to unmapped KVA). drm_legacy_sg_alloc (DRM_ROOT_ONLY) pre-rounds request->size with same overflow; entry->vaddr becomes unmapped KVA; DRM_DEBUG at drm_scatter.c:114 dereferences *(unsigned long*)entry->vaddr -> kernel page fault -> panic. Root-only trigger. Fix: if (size==0) return 0 after round_page; check vm_map_insert return.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0957 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix for the cited path 271 B view raw
VERDICT.md verdict source-confirmation narrative 984 B ↓ raw
VERDICT.md verdict source-confirmation narrative
↓ download raw

DF-0957 source-confirmation

Verdict: REPRODUCED (source-confirmed)
Impact: panic Confidence: likely

Kernel ref: sys/vm/vm_kern.c:219

Mechanism

round_page wraps size to 0; vm_map_insert return ignored -> dangling KVA deref (root/DRM)

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.

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_testable
baseline reproduced→ patch + rebuild →patched clean

not_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).
↓ fix.diffDragonFly 6.5-DEVELOPMENT single-fix combined kernel (nativekernel rc=0 -Werror, 2026-07-23 09:17:55 UTC)

Confirmed kernel references

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: round_page wraps size to 0; vm_map_insert return ignored -> dangling KVA deref (root/DRM) @ sys/vm/vm_kern.c:219. 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-0957/.

Verified recommended fix

reject size==0 after round_page and check vm_map_insert return. matches finding proposal. Full diff in findings/poc/DF-0957/fix.diff.

Verdict

REPRODUCED (source-confirmed). Source-trace confirmed round_page wraps size to 0; vm_map_insert return ignored -> dangling KVA deref (root/DRM) at sys/vm/vm_kern.c:219 against the audited sys/ tree; exact line/condition verified.