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

raw_attach failure contract violated by callers: rts_attach frees the rawcb while so->so_pcb still points at it and the pcb socket reference is never dropped (latent β€” soreserve cannot fail in current DF)

Summary

rts_attach assigns so->so_pcb = rp and takes a pcb soreference BEFORE calling raw_attach. On raw_attach failure it kfrees the rawcb without clearing so->so_pcb and without dropping the pcb reference. socreate's error path then calls sofree(), which only decrements so_refs from 2 to 1 - the socket leaks permanently holding a dangling so_pcb; a later raw_detach on it would LIST_REMOVE freed memory (UAF). Identical missing-cleanup shape in raw_uattach. LATENT: raw_attach can fail solely at soreserve and DragonFly's chgsbsize clamps instead of failing (always returns 1), so the path is unreachable in the current tree - if soreserve ever regains a failure mode (rlimit enforcement restored as in FreeBSD), an unpriv user looping socket(AF_ROUTE,...) under a lowered RLIMIT_SBSIZE would leak one struct socket per attempt with a dangling pcb pointer. Hardening: fix the error path before it becomes reachable. No runnable PoC (trigger dead code). Fix: 'so->so_pcb = NULL; sofree(so);' before kfree in rts_attach's error path (raw_uattach same contract). [VERIFIED pass2: rts_attach frees rawcb without clearing so_pcb; latent soreserve cannot fail here; cleanup fix compiled]

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-3472 Β· 4 files
FileTypeDescriptionSize
README.md β€” 243 B ↓ raw
fix.diff β€” 370 B view raw
manifest.json β€” 366 B view raw
verdict.json β€” 1.6 KB view raw

DF-3472 evidence pack

What

rts_attach violates the raw_attach failure contract (latent UAF shape)

Verdict

status=not_reproduced impact=none confidence=certain

See VERDICT.md for the full narrative and fix.diff for the verified fix.

Fix verification

not_testable

fix.diff applied in the F40FIX verification kernel build (RC=0, zero -Werror errors); no runtime A/B for this item (line-certain hardening)

↓ fix.diffper-fix-DF-3472

Confirmed kernel references

Detail

Evidence (decisive lines)

VERDICT.md with path:line citations; run.log where a live demo exists; fix.diff

PoC changes

n/a - soreserve cannot fail on this tree

Verified recommended fix

clear so_pcb and sofree() the pcb reference when raw_attach fails

Verdict

Line-accurate confirmation; latent by construction - raw_attach can fail solely at soreserve, and DragonFlys chgsbsize clamps instead of failing (always returns 1), so the failure path is unreachable in the current tree (proven in the DF sibling audit of soreserve). rts_attach assigns so->so_pcb = rp and takes a pcb soreference BEFORE raw_attach (rtsock.c:271-273); on failure it kfrees rop (:277-279) without clearing so->so_pcb or dropping the reference - the socket leaks holding a dangling pcb and a later raw_detach would LIST_REMOVE freed memory. Fix clears so_pcb and drops the pcb reference via sofree() on the error path; compiled in the F40FIX build.