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

Unchecked integer overflow in dma_fence_array_create size computation yields heap OOB write (latent, EXPORT_SYMBOL)

Summary

dma_fence_array_create computes allocation size as sizeof(*array) + num_fences * sizeof(struct dma_fence_array_cb) with no validation of num_fences (signed int) and no overflow check on multiply (fence-array.c:173-177). Negative num_fences e.g. -1: (size_t)(-1)=0xFFFFFFFFFFFFFFFF multiplied by sizeof(cb)=32 wraps to SIZE_MAX-31; adding sizeof(*array)>=200 wraps total to sizeof(*array)-32 small positive; kzalloc succeeds ~170 bytes; line 186 array->num_fences=num_fences stores (unsigned)(-1)=UINT_MAX. Loop at :92 for(i=0;i<array->num_fences;++i) cb[i].array=array writes UINT_MAX entries past allocation = catastrophic heap OOB write. Release loop at :131 likewise reads array->fences[i] OOB. DragonFly kzalloc/kmalloc no overflow detection no check_mul_overflow helper in LinuxKPI headers. EXPORT_SYMBOL callable by any kernel module. Currently NOT reachable: 3 in-tree callers all pass small bounded unsigned values (amdgpu_ids.c:135 count from reservation_object_get_fences_rcu; amdgpu_ids.c:239 i bounded by id_mgr->num_ids HW-limited; amdgpu_prime.c:221 dead code #if 0). Latent defense-in-depth: function performs zero input validation on exported API.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2153 Β· 4 files
FileTypeDescriptionSize
VERDICT.md file 742 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-2153 - Verification Verdict

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

Verdict

Source-confirmed: dma_fence_array_create (:176) computes size without overflow check on num_fences*cb_size; signed int num_fences; huge/negative wraps allocation; DRM-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/drm/linux_fence-array.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)

dma_fence_array no overflow check; DRM-gated

Verified recommended fix

dma_fence_array no overflow check; DRM-gated

Verdict

dma_fence_array no overflow check; DRM-gated