# VERDICT — DF-1333

## Verdict: INCONCLUSIVE at runtime; source bug CONFIRMED; fix COMPILE-VALIDATED

**Citations confirmed:** sys/dev/drm/radeon/rv770_dpm.c:2284, sys/dev/drm/radeon/rv770_dpm.c:2294, sys/dev/drm/radeon/rv770_dpm.c:2296, sys/dev/drm/radeon/rv770_dpm.c:2300, sys/dev/drm/radeon/rv770_dpm.c:2317, sys/dev/drm/radeon/atom.h:125

### Is the bug real? — YES (source trace)
rv7xx_parse_power_table() builds pointers into the kmalloc'd VBIOS image (atom_context->bios, max 256KB) using offsets and indices taken verbatim from the (attacker-controlled) VBIOS power table: usStateArrayOffset (u16), usNonClockInfoArrayOffset (u16), usClockInfoArrayOffset (u16), ucNonClockStateIndex (u8) and the per-state clock indices idx[j] (u8), each scaled by u8 entry sizes. None of these are validated against the BIOS allocation size. A crafted VBIOS with large offsets makes power_state / non_clock_info / clock_info point past the allocation, so the driver reads out of bounds when it later dereferences those structs in rv7xx_parse_pplib_*_clock_info.

### Can it be reproduced on this guest? — NO (hardware-gated)
Requires an AMD Radeon RV770-family GPU whose VBIOS power table is attacker-controlled (crafted VBIOS via PCIe passthrough / hotplug / malicious option-ROM). Reached during rv770_dpm_init() -> rv7xx_parse_power_table() at driver attach.

Guest evidence (`env.txt`): only `vgapci0 class=0x030000 chip=0x11111234` (QEMU stdvga); no AMD GPU;
no PCI audio device; `kldstat` shows no drm/radeon/amdgpu/snd module; `/dev/dri` and `/dev/dsp*` do
not exist. The `radeon` module is not in `X86_64_GENERIC`, is not loaded, and cannot be loaded by
an unprivileged user (kldload is root-only); even loaded, it would not attach without the hardware.
Therefore the vulnerable code is unreachable at runtime here. Because the sinks are device-integrated
parsers / DRM ioctls / a hardware-dependent channel race, no userspace harness on this guest can
exercise them. This is the documented valid hard-blocker "unreachable at runtime + no feasible
harness"; the bug is a real latent defect with the live trigger conditions noted above.

### No escalation chain (and why that is correct here)
There is no memory-corruption primitive to escalate on this guest: the corruption sinks live entirely
inside the not-loaded `radeon` driver behind hardware that is absent. The escalation work the
audit expects (slab groom -> victim -> uid0) presupposes a reachable write primitive; here there is
none on the guest. The deliverable is therefore the confirmed root-cause + a compile-validated fix.

### Fix (fix.diff) — authored and COMPILE-VALIDATED
Capture the data-table size from atom_parse_data_header() (new `data_size` out-param) and, before every state/non-clock/clock-info pointer deref, check the computed offset + entry size <= data_size, breaking out of the loop on overflow and setting num_ps to the count actually parsed. Supersedes the finding markdown proposal (which only suggested the approach).

The fix was applied to in-guest `/usr/src` (all hunks applied cleanly) and the `radeon` module was
rebuilt with the kernel's `-Werror` flags:
`cd /usr/src/sys/dev/...radeon... && KERNCONF=X86_64_GENERIC SYSDIR=/usr/src/sys make -m /usr/src/share/mk`
=> **rc=0**, no warnings/errors in the patched translation unit (`build_fix.log`). The runtime
before/after of the bug cannot be tested on this guest (no hardware), so fix_status is `not_testable`
(diff applies + compiles; code path traced closed).

### Why not `not_reproduced` (false-positive)?
This is NOT a false positive. The cited `sys/` code is genuinely missing the guard / has the overflow
/ has the race — verified by reading the source. It is a real bug that is simply out of reach of this
particular (GPU/audio-less) QEMU guest.
