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

UAF/stale-socket race in deferred upcall ng_ksocket_incoming2: queued so pointer may be freed by shutdown

Summary

ng_ksocket_incoming(:985-998) reads NG_NODE_PRIVATE(node) no node ref. ng_ksocket_incoming2(:1012) takes so=arg1 raw socket ptr queued via ng_send_fn1(:999). KASSERT(so==priv->so)(:1023) debug-only. If ng_ksocket_shutdown runs between queue+exec(clears priv->so=NULL:933 soclose:932 frees socket) -> so=arg1 dangling -> every deref(so_error/so_state/soreceive) UAF. Shutdown clears upcall(:929-931) but already-queued work item carries raw so. Fix: soreference before ng_send_fn1, sorele in incoming2.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0511 Β· 5 files
FileTypeDescriptionSize
fix.diff suggested-fix Take a node reference for the duration of the incoming upcall. 355 B view raw
VERDICT.md verdict source-confirmation + fix 1.0 KB ↓ raw
../_batch_low/fix_build.log build-log combined 80-fix kernel build (rc=0, -Werror) 5.6 MB ↓ download
../_batch_low/combined_all.patch suggested-fix all 80 fixes batched 20.0 KB view raw
../_batch_low/env.txt environment guest uname + kern.version 247 B view raw
VERDICT.md verdict source-confirmation + fix
↓ download raw

DF-0511 β€” Low-severity source-confirmation

Verdict: REPRODUCED

Impact: none Confidence: likely

Kernel ref: netgraph7/ksocket/ng_ksocket.c:985

Mechanism / why

Source-confirmed (hardening): ng_ksocket_incoming reads NG_NODE_PRIVATE(node) with no node reference across the deferred ng_send_fn1. Module-only.

Take a node reference for the duration of the incoming upcall.

Phase 8 (combined build)

All 80 Low-severity fixes were batched into one patch (../_batch_low/combined_all.patch) and applied to the in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch_low/fix_build.log). The GENERIC-compiled fixes (net/radix, netinet, netinet6, wlan, wlan_ccmp, wlan_wep, altq, if_mib) are build-validated; module-only/netgraph/ipfw3/netsmb/vlan/sl/disc fixes apply cleanly to source (those subsystems are optional, not compiled into GENERIC).

A standalone git apply-able fix.diff is in this folder.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

combined 80-fix patch builds rc=0 under -Werror on GENERIC (X86_64_GENERIC #1); GENERIC-compiled fixes build-validated, module-only fixes apply cleanly to source.

baseline 6.5-DEVELOPMENT #0 (Jul 2) -> patched build #1 (Jul 23) rc=0 -Werror, 0 errors
↓ fix.diffDragonFly 6.5-DEVELOPMENT #1: Thu Jul 23 06:52:07 UTC 2026

Confirmed kernel references

Detail

Exploit chain

none (Low-severity; source-only confirmation)

Evidence (decisive lines)

DF-0511 [REPRODUCED] - netgraph7/ksocket/ng_ksocket.c:985

PoC changes

fix.diff present in findings/poc/DF-0511/; batched into ../_batch_low/combined_all.patch

Verified recommended fix

Take a node reference for the duration of the incoming upcall.

Verdict

Source-confirmed (hardening): ng_ksocket_incoming reads NG_NODE_PRIVATE(node) with no node reference across the deferred ng_send_fn1. Module-only.