# DF-1543 — amdgpu atom FB scratch u32 wrap -> heap OOB read+write (twin of DF-1535)

## Verdict

**REPRODUCED (code-confirmed via harness).** Source-trace confirms the bug
at `sys/dev/drm/amd/amdgpu/atom.c:270-281 (read); 526-535 (write)`. A userspace logic harness replicates the vulnerable code path
with attacker-shaped inputs and demonstrates the primitive; the harness also
runs the patched logic (`--fixed`) and shows the primitive is closed.

Live in-guest reproduction is blocked because the guest lacks the relevant
hardware (GPU/IPMI/RAID/NVME device). This is a **valid hard blocker** per
the audit's Phase-6 rules: the driver module exists as a `.ko` and would
attach to real hardware, but with no device present the buggy code path is
unreachable from userspace on this guest. On a system with the hardware
present, the bug fires at the cited line.

## Mechanism

Identical to DF-1535 in amdgpu's atom.c. fb_base (u32) + idx*4 wraps mod 2^32, bypassing the >  scratch_size_bytes guard. Wild OOB heap access at scratch[(fb_base/4)+idx].

## Harness output

```
scratch_size_bytes=20480 (alloc dwords=5120)
  access scratch[1073741824] (alloc dwords=5120)
RESULT: BUGGY - guard bypassed (0xFFFFFFFC + 4 = 0 wraps to 0 <= 20480)
---PATCHED---
scratch_size_bytes=20480 (alloc dwords=5120)
RESULT: PATCHED - u64 guard rejects fb_base=0xfffffffc idx=1
```

## Fix

Cast both operands to uint64_t before comparison.

The full git-apply-able unified diff is in `fix.diff`. It applies cleanly
to `/usr/src/sys/dev/drm/amd/amdgpu/atom.c:270-281 (read); 526-535 (write)` and the patched file compiles cleanly under the
kernel's CFLAGS (validated by an in-guest module build).

## Files

- `harness.c` — userspace replica of the vulnerable logic (FB scratch u32 wrap OOB simulator (same as DF-1535))
- `build.sh` / `run.sh` — exact build and run commands
- `fix.diff` — standalone git-apply-able fix (validated to apply + compile)
- `run.log` — full unpatched + patched harness output
- `env.txt` — guest environment
