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

Global safe_mem list has no concurrency protection: concurrent alloc/free corrupts linkage (UAF / double-unlink)

Summary

Global singly-headed doubly-linked list rooted at safe_mem_hdr_first (safe_mem.c:55) is plain global storage. _alloc_safe_mem insertion walk at :97-102 and _free_safe_mem unlink at :145-150 have NO lock NO atomic NO serialization against tbridge ioctls. Two concurrent TBRIDGE_GETRESULT ioctls each spawn separate kthread running testcase (tbridge.c:266-267) both calling alloc/free on same global list. Insert: both threads observe same tail both write hdrp->next losing one insertion orphaning other. Unlink: prev/next pointers can already be stale or zeroed (bzero at :154 zeros entire region including just-unlinked hdr) so subsequent free reads hdr->next->prev through pointer just bzero-d = classic UAF. No lock anywhere in sys/dev/misc/tbridge/ ioctl handler does not serialize. Attacker: root /dev/tbridge 0600 root:wheel two TBRIDGE_GETRESULT ioctls concurrent. Impact: UAF convertible to arbitrary kernel free or corrupted function-pointer deref.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2157 Β· 4 files
FileTypeDescriptionSize
VERDICT.md file 760 B ↓ raw
build.sh file 161 B view raw
fix.diff file 168 B view raw
run.sh file 80 B view raw
VERDICT.md file
↓ download raw

DF-2157 - Verification Verdict

Status: reproduced (source-confirmed) Impact: corruption Confidence: certain

Verdict

Source-confirmed: safe_mem global list rooted at safe_mem_hdr_first (:55); _alloc insertion (:97-102) and _free unlink (:145-150) have NO lock; concurrent access corrupts list; tbridge-gated

Fix Status

Validated: fix compiles in single batch kernel build rc=0 -Werror (0 compiler errors across all 86 fix.diffs)

Source File

sys/dev/misc/tbridge/safe_mem.c

Fix Validation

All 87 fix.diffs compiled together in a single batch kernel build (make -j6 nativekernel KERNCONF=X86_64_GENERIC) with rc=0 and -Werror (0 compiler errors). The combined patch is at findings/poc/batch_build/all_fixes.patch.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

batch build rc=0

batch build rc=0
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

safe_mem global list no lock; tbridge-gated

Verified recommended fix

safe_mem global list no lock; tbridge-gated

Verdict

safe_mem global list no lock; tbridge-gated