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

parse_mipi_sequence: 1-byte heap OOB read of the kmemdup'd sequence blob when MIPI_SEQ_ELEM_END is the final byte

Summary

goto_next_sequence returns the index past an ELEM_END byte; if that byte is the blob's last it returns exactly seq_size, and the loop then reads *(data+index) one byte past the exact-size kmemdup allocation. The stray byte only gates bounded control flow. HARNESS-REPRODUCED (SIGSEGV at exactly +5 on a 5-byte guard-terminated blob, 3/3; -p exits 0). index>=seq_size guard fix.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-4123 Β· 11 files
FileTypeDescriptionSize
README.md β€” 1.4 KB ↓ raw
VERDICT.md β€” 2.9 KB ↓ raw
build.sh β€” 94 B view raw
env.txt β€” 390 B view raw
fix.diff β€” 579 B view raw
fix_run.log β€” 343 B view raw
run.2.log β€” 401 B view raw
run.3.log β€” 401 B view raw
run.log β€” 401 B view raw
run.sh β€” 127 B view raw
vbt_oob_harness.c β€” 19.6 KB view raw

DF-4123 β€” parse_mipi_sequence: 1-byte heap OOB read of the kmemdup'd sequence blob when an element-END is the final byte

  • File: sys/dev/drm/i915/intel_bios.c
  • Lines: 1134-1158 Severity: Low Confidence: certain
  • Status: reproduced (impact: leak) β€” hardware-gated crafted-VBIOS/firmware threat model; harness-reproduced on the DragonFly guest.

Summary

In parse_mipi_sequence() the loop at intel_bios.c:1134-1158 reads u8 seq_id = *(data + index) where data is an exact-size kmemdup'd buffer of seq_size bytes (intel_bios.c:1129). goto_next_sequence() returns the index just past an MIPI_SEQ_ELEM_END byte; if that byte is the LAST byte of the blob (a truncated-but-walk-consistent panel sequence), it returns exactly seq_size, and the next loop iteration reads data[seq_size] β€” one byte past the end of the heap allocation (slab OOB read). The byte read this way becomes a sequence id: if it happens to be MIPI_SEQ_END the loop stops; otherwise it indexes dsi.sequence[seq_id] and re-enters goto_next_sequence (which then returns 0 -> err path). 1-byte read; disclosed value only gates control flow into bounded paths.

Reproduce (harness)

./build.sh && ./run.sh β€” exit 77 = OOB/div0 confirmed by verbatim kernel code; -p run = proposed fix, exit 0.

Guest: DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

VERDICT.md
↓ download raw

DF-4123 verdict β€” parse_mipi_sequence: 1-byte heap OOB read of the kmemdup'd sequence blob when an element-END is the final byte

Reproduced? β€” reproduced (leak)

Harness-reproduced: crafted BDB_MIPI_SEQUENCE (v1) whose panel sequence payload is [DEASSERT_RESET][GPIO elem, 3 bytes][ELEM_END as final byte] β€” the verbatim goto_next_sequence returns exactly seq_size=5 and the verbatim parse loop reads data[5] on a 5-byte guard-terminated buffer: SIGSEGV at exactly +5, exit 77, stable across 3 runs (run.log). In-kernel analog: 1-byte slab OOB read past kmemdup(seq_data, seq_size). Minimal standalone impact (single byte gating bounded control flow); filed as Low.

Root cause (path:line)

In parse_mipi_sequence() the loop at intel_bios.c:1134-1158 reads u8 seq_id = *(data + index) where data is an exact-size kmemdup'd buffer of seq_size bytes (intel_bios.c:1129). goto_next_sequence() returns the index just past an MIPI_SEQ_ELEM_END byte; if that byte is the LAST byte of the blob (a truncated-but-walk-consistent panel sequence), it returns exactly seq_size, and the next loop iteration reads data[seq_size] β€” one byte past the end of the heap allocation (slab OOB read). The byte read this way becomes a sequence id: if it happens to be MIPI_SEQ_END the loop stops; otherwise it indexes dsi.sequence[seq_id] and re-enters goto_next_sequence (which then returns 0 -> err path). 1-byte read; disclosed value only gates control flow into bounded paths.

Chain

crafted MIPI sequence blob ending in MIPI_SEQ_ELEM_END -> goto_next_sequence returns seq_size -> parse loop reads data[seq_size] -> 1-byte OOB read of exact-size kmemdup heap buffer

Kernel refs

Fix

Bail to the existing err path (which frees data and clears sequence[]) when the walker consumed the whole blob. Harness -p mode: loop stops at index==seq_size without reading (fix_run.log).

fix.diff applies cleanly against the read-only sys/ tree (2-file for DF-4125; note the radeon_pm.c hunk also needs dpm_failed_unlock: mutex_unlock(&rdev->pm.mutex); added to the existing dpm_failed label path β€” spelled out here since the label does not exist in the unfixed tree). Kernel-level fix validation is not possible on this guest (no i915/RV6xx devices; the drivers never attach in QEMU); harness-level fix validation IS included: the -p runs exercise the patched parse logic against the identical crafted input and exit 0 (fix_run.log).

Fix status (batch validation)

Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.

Fix verification

inconclusive
baseline reproduced→ patch + rebuild →patched clean

harness-level: the -p runs apply the proposed guard to the same verbatim code and the crafted input is rejected without OOB/div0 (fix_run.log exit 0 vs run.log exit 77); kernel-level build/boot validation impossible on this guest (no i915/RV6xx hardware)

fix_run.log + fix.diff
↓ fix.diffDragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64

Confirmed kernel references

Detail

Exploit chain

crafted MIPI sequence blob ending in MIPI_SEQ_ELEM_END -> goto_next_sequence returns seq_size -> parse loop reads data[seq_size] -> 1-byte OOB read of exact-size kmemdup heap buffer

Evidence (decisive lines)

run.log (SIGSEGV at offset +5 on the 5-byte blob, exit 77), run.2.log/run.3.log, fix_run.log (index>=seq_size break, exit 0)

PoC changes

Source-faithful userland harness (verbatim kernel parse code); guard-page buffers stand in for the kernel heap/mappings; volatile inputs defeat constant folding of the division (gcc folds literal 0/0).

Verified recommended fix

Bail to the existing err path (which frees data and clears sequence[]) when the walker consumed the whole blob.

Verdict

Harness-reproduced: crafted BDB_MIPI_SEQUENCE (v1) whose panel sequence payload is [DEASSERT_RESET][GPIO elem, 3 bytes][ELEM_END as final byte] β€” the verbatim goto_next_sequence returns exactly seq_size=5 and the verbatim parse loop reads data[5] on a 5-byte guard-terminated buffer: SIGSEGV at exactly +5, exit 77, stable across 3 runs (run.log). In-kernel analog: 1-byte slab OOB read past kmemdup(seq_data, seq_size). Minimal standalone impact (single byte gating bounded control flow); filed as Low.