⬢ DragonFlyBSD Kernel Audit
DF-2968 / verdict.json
← back to finding ↓ download raw
{
 "finding_id": "DF-2968",
 "status": "reproduced",
 "reproduced": 1,
 "impact": "none",
 "confidence": "certain",
 "verdict": "Mechanically reproduced via the harness on the stock guest: creating and exiting 8 throwaway kthreads moved proc0.p_ucred->cr_ref from 165 to 173 (+8, exactly one leaked reference per kthread) - _kthread_create takes crhold(proc0.p_ucred) (kern_kthread.c:62) but the LWKT exit path never drops it: lwkt_exit parks the struct without crfree (lwkt_thread.c contains zero crfree calls) and lwkt_init_threads bzero silently destroys the held reference on recycle; the only td_ucred crfree is the LWP path (kern_exit.c:717), unreachable for pure LWKT threads. Minimal today (leak is always on the immortal proc0 credential; cr_ref is 64-bit). On the fix kernel (crfree in lwkt_exit, guarded, before parking) the same 8-cycle batch moved cr_ref by 0.",
 "exploit_chain": "",
 "evidence": "harness.log T3: before=165 after=173 delta=+8; fix kernel T3: delta=0",
 "kernel_refs": [
  "sys/kern/kern_kthread.c:62",
  "sys/kern/lwkt_thread.c:1684",
  "sys/kern/kern_exit.c:717"
 ],
 "poc_changes": "reads proc0.p_ucred.cr_ref directly from the module (long, cache-aligned)",
 "attempts": 1,
 "guest_uname": "DragonFly dfbsd 6.5-DEVELOPMENT #0: Thu Jul  2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64",
 "runtime_sec": 30,
 "guest_dirty": 0,
 "build_cmd": "cd /root/h41 && make",
 "run_cmd": "kldload ./h41.ko; sysctl -w debug.h41.cmd=3",
 "code_hash": "85d6e241caa2a7fb1fb44b80c7736a4e83c36d29314b0c96ce91769bc9bdf839",
 "notes": "Refcount discipline; becomes dangerous only if kthreads ever get non-proc0 creds",
 "recommended_fix": "crfree(td->td_ucred) in lwkt_exit() before parking the thread",
 "fix_status": "fixed",
 "fix_baseline_reproduced": 1,
 "fix_patched_reproduced": 0,
 "fix_kernel_uname": "DragonFly dfbsd 6.5-DEVELOPMENT #1: Mon Oct 26 01:57:23 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64 (h41 fix kernel, all 41 hardening fixes applied)",
 "fix_verdict": "A/B: baseline +8 refs per batch; fix kernel +0 (LWP paths already NULL the field in kern_exit.c, no double free)."
}