# PoC DF-1515: intel_overlay.c divide-by-zero via zero dst dimensions

**Class:** Divide-by-zero (#DE) -> kernel panic
**Cited site:** `sys/dev/drm/i915/intel_overlay.c:916-929, 931-945`

## Reproduction status

HW/module gated — **cannot be live-triggered on the audit QEMU guest.**

The audit guest has only virtio + PIIX3 PCI devices (`pciconf -lv` shows no
AMD/Intel GPU, no ath NIC, no AdvanSys SCSI, no mfi/tws/mrsas RAID, etc.),
so the cited code path is not reachable at runtime on this guest.

The bug is **confirmed at the source level** by tracing the cited path:line
in `sys/dev/drm/i915/intel_overlay.c` and confirming the vulnerable code is
present in the master DEV kernel tree. The `fix.diff` in this folder is
validated to apply cleanly and compile under `-Werror` (see `VERDICT.md`).

## Mechanism

check_overlay_dst validates dst_x+dst_width <= pipe_src_w but never rejects zero width/height (0+0<=pipe_src_h always true). check_overlay_scaling at 936 then computes ((src_scan_height<<16)/rec->dst_height)>>16 with dst_height==0 -> x86 #DE trap -> kernel panic. Same for dst_width==0 at line 940.

## Realistic impact ceiling (on suitable HW)

kernel panic (DoS) via DRM ioctl from unprivileged DRI client on i915 GPU

## Fix

Reject zero dst_width/dst_height in check_overlay_dst before the divide.

See `fix.diff` for the git-apply-able patch.

## How to validate the fix

```sh
scp -F dfbsd-qemu/config fix.diff dfbsd:/root/DF-1515.diff
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src && patch -p1 --forward < /root/DF-1515.diff'
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src && make -j6 nativekernel KERNCONF=X86_64_GENERIC'
# rc=0 expected; see fix_apply.log + fix_build.log in this folder.
```
