โฌข DragonFlyBSD Kernel Audit
DF-0220 / final_verify.txt
โ† back to finding โ†“ download raw
================================================================================
DF-0220 โ€” end-to-end re-verification (2026-07-03)
================================================================================
Sequence (all on the unpatched audit-source kernel 6.5-DEVELOPMENT #0,
Thu Jul 2 06:02:54 UTC 2026):

  1. vm.sh reset with-src                                -> up, #0 unpatched
  2. deploy + build rand_probe, ref_keystream            -> BUILT_OK
  3. boot1: vm.sh run_user './rand_probe'                -> see boot1_probe.txt
  4. vm.sh reset with-src                                -> up, fresh independent boot
  5. redeploy + build                                    -> BUILT
  6. boot2: vm.sh run_user './rand_probe'                -> see boot2_probe.txt
  7. vm.sh reset with-src                                -> up, fresh independent boot
  8. redeploy + build                                    -> BUILT
  9. boot3: vm.sh run_user './rand_probe'                -> see boot3_probe.txt
 10. ref_keystream 64                                    -> all-zero (fixed point)
 11. sysctl kern.rand_mode=csprng; 3 reads               -> all non-zero, distinct
 12. compile sizeof check via DWARF/gdb on kernel.debug  -> sizeof(globaldata)=14976
 13. source trace rand_initialize / csprng_reseed        -> reseed runs in SYSINIT
                                                            (SI_BOOT2_POST_SMP),
                                                            before init(8)
                                                            (SI_SUB_KTHREAD_INIT)
 14. fix.diff regenerated with proper git headers;
     patch -p1 --dry-run on /usr/src/sys/kern/subr_csprng.c
                                                        -> Hunk #1 succeeded at 138
 15. cc -fsyntax-only of patched TU                      -> rc=0 (only an unrelated
                                                            'log' builtin warning)

================================================================================
RESULT
================================================================================
Cross-boot RNG comparison (3 independent fresh boots):
  /dev/urandom:  3 boots pairwise differ in 64/64 bytes; never matches all-zero ref
  getrandom(2):  3 boots pairwise differ in 64/64 bytes; never matches all-zero ref
  kern.random:   3 boots pairwise differ in 64/64 bytes; never matches all-zero ref

csprng-only mode (rand_mode=csprng) returns non-zero distinct bytes on every read,
proving the csprng cipher context is keyed (reseed_cnt > 0) before userspace.

=> BUG NOT REPRODUCED. The userspace-observable pre-reseed window the finding
   relies on does not exist on DragonFly master DEV: rand_initialize() (a
   SI_BOOT2_POST_SMP SYSINIT) feeds sizeof(struct globaldata)=14976 bytes into
   csprng pool[0] via RAND_SRC_THREAD2 (kern_nrandom.c:539-543) โ€” far beyond
   MIN_POOL_SIZE=96 โ€” so the first read_random at kern_nrandom.c:558 triggers
   a successful csprng_reseed that keys the cipher BEFORE init(8) runs.

VERDICT: not_reproduced (false-premise: finding omits the per-CPU globaldata
         entropy feed that closes the pre-reseed window during kernel SYSINIT).
fix_status: not_applicable (no reproduced bug to validate a fix against; the
            fix.diff remains as defense-in-depth hardening โ€” applies cleanly
            and compiles, but the patched kernel would behave identically to
            the unpatched one).