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

Memory leak of usrbufs array on I2CRDWR copyin-failure path

Summary

I2CRDWR at iic.c:352 allocates usrbufs = kmalloc(sizeof(void*)*d->nmsgs, M_TEMP, M_ZERO|M_WAITOK). If copyin of message array at :353 fails, execution breaks at :355. Function-level cleanup at :385-386 only frees buf - usrbufs never freed. Leaks sizeof(void*)*nmsgs bytes per failed call. Root can pass large nmsgs (100000) with invalid d->msgs pointer to leak ~800KB per ioctl. Repeated in tight loop exhausts kernel malloc memory. Fix: add kfree(usrbufs) to cleanup and null after happy-path free.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1110 Β· 3 files
FileTypeDescriptionSize
VERDICT.md verdict Source-confirmation verdict for DF-1110 604 B ↓ raw
fix.diff suggested-fix Free usrbufs on copyin failure path 962 B view raw
../fix_build.log build-log Batch kernel build log (all fixes, rc=0) 5.6 MB ↓ download
VERDICT.md verdict Source-confirmation verdict for DF-1110
↓ download raw

DF-1110 Verification Verdict

Severity: Low Impact class: leak Verification method: Source-only confirmation (HW-gated, not triggerable on QEMU guest)

Verdict: REPRODUCED (source-confirmed)

The bug is confirmed in the audited source at the cited path:line. Triggerable but requires specific driver/config.

Fix: Free usrbufs on copyin failure path

Fix applied and validated in batch kernel build (rc=0, -Werror).

Fix validation

All 41-fix patches batched into single make -j6 nativekernel KERNCONF=X86_64_GENERIC build. Build result: rc=0, 0 errors (full -Werror clean).

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.

VALIDATED: fix.diff applies cleanly + batch kernel build rc=0 -Werror; bug HW/module/runtime-gated, no runtime PoC re-test possible on guest.
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

REPRODUCED (source-only): I2CRDWR allocates usrbufs = kmalloc(sizeof(void*)*d->nmsgs); on copyin failure the break skips per-msg free loop, leaking usrbufs and any partially-allocated m->buf entries.

Verified recommended fix

REPRODUCED (source-only): I2CRDWR allocates usrbufs = kmalloc(sizeof(void)d->nmsgs); on copyin failure the break skips per-msg free loop, leaking usrbufs and any partially-allocated m->buf entries.

Verdict

REPRODUCED (source-only): I2CRDWR allocates usrbufs = kmalloc(sizeof(void)d->nmsgs); on copyin failure the break skips per-msg free loop, leaking usrbufs and any partially-allocated m->buf entries.