DragonFlyBSD Kernel Audit
DF-0613 / env.txt
← back to finding ↓ download raw
DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Fri Jul  3 17:30:11 UTC 2026    root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC.noinv  x86_64
Kernel: DragonFly 6.5-DEVELOPMENT #0: Fri Jul  3 17:30:11 UTC 2026
Compiler: cc 8.3 [DragonFly] Release/2019-02-22
vm.randomize_mmap: 0

NOTE: Fix validation was performed on the noinv-installed snapshot
(X86_64_GENERIC.noinv, INVARIANTS OFF) because the default GENERIC
kernel (INVARIANTS ON) has two separate bugs that prevent ng_iface node
creation at runtime:

1. kfree(NULL) panic in ng_iface_get_unit():
   bcopy() is declared __nonnull(1,2) in sys/sys/systm.h:280.
   The compiler (gcc 8.3) uses this to eliminate the
   `if (ng_iface_units != NULL)` check before kfree() at
   ng_iface.c:294, causing a panic on the first ng_iface_get_unit()
   call when ng_iface_units is still NULL.

2. ifnet_lock KASSERT in if_attach():
   ifnet_lock() has `KASSERT(td_type != TD_TYPE_NETISR)` at
   sys/net/if.c:3787. The ng_socket send path runs in a netisr
   thread context, so ng_iface_constructor() calling if_attach()
   triggers the KASSERT (INVARIANTS-gated, only on GENERIC).

A test-only constructor fix (changing `if (ng_iface_units != NULL)`
to `if (ng_iface_units_len > 0)`) was applied to both the BEFORE
and AFTER ng_iface.ko modules to work around issue (1). Issue (2)
is bypassed on the noinv kernel (KASSERT is INVARIANTS-gated).

The DF-0613 fix.diff contains ONLY the EBUSY return→break change,
not the constructor fix.

Modules loaded during testing:
  netgraph.ko  (from with-src snapshot)
  ng_socket.ko (from with-src snapshot)
  ng_iface.ko  (rebuilt with constructor fix [+ EBUSY fix for AFTER])