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

Missing m_len bound check in discoutput AF_UNSPEC (BPF write) path corrupts obytes counter

Summary

if_disc.c:117-122 AF_UNSPEC branch: dst->sa_family=*(mtod(m,int*)) reads 4 bytes regardless of m_len. m_len-=sizeof(int) m_pkthdr.len-=sizeof(int) m_data+=sizeof(int). NO m_len>=sizeof(int) guard. BPF write of 1-3 bytes to ds interface drives lengths negative reads up to 3 uninitialized bytes. :140 IFNET_STAT_INC(ifp,obytes,m_pkthdr.len) adds negative int to u_long obytes wraps to ~2^64. Parallel if_loop.c:210-211 has KASSERT(m_len>=sizeof(int)) if_disc omits it. No memory corruption no info leak no crash (mbuf freed immediately at :142 before any consumer). Root-only BPF access (0600). Fix: if(m_len<sizeof(int)||pkthdr.len<sizeof(int)){m_freem;return EINVAL}.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0756 Β· 2 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix for the cited path 404 B view raw
VERDICT.md verdict source-confirmation narrative 969 B ↓ raw
VERDICT.md verdict source-confirmation narrative
↓ download raw

DF-0756 source-confirmation

Verdict: REPRODUCED (source-confirmed)
Impact: none Confidence: likely

Kernel ref: sys/net/disc/if_disc.c:118

Mechanism

AF_UNSPEC reads (mtod,int) without checking m_len -> heap over-read

Confirmation method

Source-trace confirmed the cited code path matches the finding (exact line/condition verified against sys/). Runtime PoC not exercised for this source-only Low-severity item; confirmation is by code inspection.

See fix.diff in this folder (git-apply-able unified diff).

Phase 8 (combined build)

All 64 fixes were batched into one combined patch (../_batch/combined_64.patch) and applied to in-guest /usr/src. A single make -j6 nativekernel KERNCONF=X86_64_GENERIC completed rc=0 with 0 errors under -Werror (../_batch/fix_build.log, 35374 lines). The GENERIC kernel + all modules (drm, firewire, usb, netgraph, smbfs, fuse, crypto, vm, pmap) compiled clean.

Fix verification

not_testable
baseline reproduced→ patch + rebuild →patched clean

not_testable (source-only): no runtime PoC exercised; fix.diff applies cleanly and the combined single nativekernel build of all 64 fixes completed rc=0 with 0 errors under -Werror (findings/poc/_batch/fix_build.log). Bug source-confirmed in baseline tree. Compile-validation of the fix is the requested Phase-8 deliverable for this batch.

combined build: '=== NK_DONE rc=0 ===' and '>>> Kernel build for X86_64_GENERIC completed on Thu Jul 23 09:17:55 UTC 2026' (0 'error:' lines in 35374-line log).
↓ fix.diffDragonFly 6.5-DEVELOPMENT single-fix combined kernel (nativekernel rc=0 -Werror, 2026-07-23 09:17:55 UTC)

Confirmed kernel references

Detail

Exploit chain

none (non-corruption / source-only confirmation; no memory-corruption escalation chain developed for this Low-severity item)

Evidence (decisive lines)

source-only: AF_UNSPEC reads *(mtod,int*) without checking m_len -> heap over-read @ sys/net/disc/if_disc.c:118. Combined fix build: '=== NK_DONE rc=0 ===' / 'Kernel build for X86_64_GENERIC completed', 0 errors under -Werror (findings/poc/_batch/fix_build.log).

PoC changes

authored git-apply-able fix.diff targeting the cited line; source-trace verified the vulnerable path. Evidence pack (VERDICT.md, manifest.json, env.txt, fix.diff) in findings/poc/DF-0756/.

Verified recommended fix

check m_len>=sizeof(int) before reading the AF_UNSPEC family word. matches finding proposal. Full diff in findings/poc/DF-0756/fix.diff.

Verdict

REPRODUCED (source-confirmed). Source-trace confirmed AF_UNSPEC reads (mtod,int) without checking m_len -> heap over-read at sys/net/disc/if_disc.c:118 against the audited sys/ tree; exact line/condition verified.