DragonFlyBSD Kernel Audit
DF-3055 / verdict.json
← back to finding ↓ download raw
{
  "finding_id": "DF-3055",
  "status": "reproduced",
  "reproduced": 1,
  "impact": "panic",
  "confidence": "certain",
  "verdict": "REPRODUCED (deterministic harness; dirfs vkernel-only, no live-boot test). When dirfs_alloc_file fails after the host symlink()/mkdirat() succeeded (fstatat loses a create/remove race with a same-uid process), dirfs_nsymlink runs its success block anyway: :1196-1197 clobber the real error with STALE libc errno (0 -> returns SUCCESS for a failed symlink), :1199 cache_setvp(nch, NULL) negative-caches a name whose object EXISTS, and :1200 dirfs_knote(*vpp==NULL) dereferences KNOTE(&NULL->v_pollinfo.vpi_kqinfo.ki_note) -> SIGSEGV. dirfs_nmkdir :1070/:1072 has the same clobber + negative-cache. Harness proves the errno-clobber table and the SIGSEGV; fixed variant (gate success block on error==0) propagates ENOENT and survives.",
  "exploit_chain": "vkernel user: symlink() loop in dirfs dir + concurrent unlink() by same-uid process (another vkernel proc or host shell) -> occasionally fstatat(ENOENT) after successful symlink() -> dirfs_nsymlink :1200 KNOTE(NULL->v_pollinfo) -> vkernel panic (DoS). Non-crash residue on near-misses: negative-cache of an existing name (lookups return ENOENT until invalidation) and errno-clobbered returns (incl. fake success).",
  "evidence": "harness.c + knote.c (two-TU transcription; KNOTE/knote machinery separate, mirroring dirfs_vnops.c vs kern_event.c); run.log: errno table showing 'stale errno=0 -> returns 0 (SUCCESS despite failure!)' and '[nsymlink-vuln] child killed by SIGSEGV -- NULL DEREF at dirfs_knote(*vpp) CONFIRMED'; fixed variant returns 2 (real ENOENT). run.2/run.3 identical.",
  "kernel_refs": [
    "sys/vfs/dirfs/dirfs_vnops.c:1194",
    "sys/vfs/dirfs/dirfs_vnops.c:1196",
    "sys/vfs/dirfs/dirfs_vnops.c:1199",
    "sys/vfs/dirfs/dirfs_vnops.c:1200",
    "sys/vfs/dirfs/dirfs_vnops.c:1067",
    "sys/vfs/dirfs/dirfs_vnops.c:1070",
    "sys/vfs/dirfs/dirfs_vnops.c:1072",
    "sys/vfs/dirfs/dirfs_vnops.c:139",
    "sys/sys/event.h:168",
    "sys/vfs/dirfs/dirfs_subr.c:196",
    "sys/vfs/dirfs/dirfs_subr.c:202",
    "sys/vfs/dirfs/dirfs_subr.c:212",
    "sys/kern/vfs_syscalls.c:kern_symlink"
  ],
  "poc_changes": "Harness written fresh (no seed). 6 attempts to make the NULL deref survive gcc 8's optimizer: empty-branch KNOTE removed by DCE; volatile-pointer cast was not a volatile lvalue; noinline knote still IPA-folded; volatile function pointer devirtualized; __attribute__((optnone)) ignored by cc 8.3; FINAL: two-TU build with the knote/KNOTE machinery in knote.c and a volatile-qualified list head -> load cannot be elided, SIGSEGV reproduces deterministically. All 6 iterations documented in the harness header comment.",
  "attempts": 6,
  "guest_uname": "DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 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": 10,
  "guest_dirty": 0,
  "build_cmd": "cd poc/DF-3055 && sh build.sh  # cc -O2 -Wall -o harness harness.c knote.c",
  "run_cmd": "cd poc/DF-3055 && sh run.sh",
  "code_hash": "f6c0f352f5ea8b8c088f1aa2e8fe382d22194423829e55745459830edb95b2de",
  "notes": "kern_symlink/kern_mkdir initialize vp=NULL before the VOP, so *vpp is NULL on alloc_file failure (alloc_file assigns *vpp only on success, subr:212-213). DF-0856 covers the alloc_file LEAK; this finding is the vnops-side aftermath. Race window is the standard create/remove race \u2014 winnable in a loop.",
  "recommended_fix": "dirfs_nsymlink/dirfs_nmkdir: only run cache_setvp/dirfs_knote when dirfs_alloc_file returned 0; propagate its error instead of overwriting it with stale errno.",
  "fix_status": "not_testable",
  "fix_kernel_uname": "DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul  2 06:02:54 UTC 2026     root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC  x86_64",
  "fix_baseline_reproduced": 1,
  "fix_patched_reproduced": 1,
  "fix_verdict": "fix.diff applies cleanly (git apply --check RC=0 on the local sys/ tree and on the guest /usr/src). Compile-neutral: patched vs unpatched dirfs_vnops.o/dirfs_subr.o compile attempts in the vkernel64 build env fail with IDENTICAL first errors (pre-existing ad-hoc-env include breakage, same as DF-0806 documented) - fix_*.log in this pack. Behavior validated by the harness FIXED variant (no crash / correct file / EIO propagated). Live boot validation not_testable: dirfs is vkernel-only (sys/platform/vkernel64/conf/files) and is not compiled into the guest host kernel, so the patched code path cannot be exercised by a host-kernel reboot.",
  "fix_evidence": "fix.diff; fix_base_vnops.log vs fix_p3055_vnops.log (identical first error); harness FIXED variant output in run.log"
}