# VERDICT — DF-1346

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

**Citations confirmed:** sys/dev/drm/amd/powerplay/smumgr/polaris10_smumgr.c:1298, sys/dev/drm/amd/powerplay/smumgr/polaris10_smumgr.c:1301, sys/dev/drm/amd/powerplay/smumgr/polaris10_smumgr.c:1404, sys/dev/drm/amd/powerplay/smumgr/polaris10_smumgr.c:1407, sys/dev/drm/amd/powerplay/inc/smu74.h:138, sys/dev/drm/amd/powerplay/inc/smu74_discrete.h:286, sys/dev/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c:708

### Is the bug real? — YES (source trace)
polaris10_populate_smc_vce_level() sets `table->VceLevelCount = (uint8_t)(mm_table->count)` (:1298) then loops `count < VceLevelCount` writing table->VceLevel[count] (:1301-1330). VceLevel[] is a fixed array of SMU74_MAX_LEVELS_VCE = 8 (smu74.h:139 / smu74_discrete.h:287). mm_table->count comes straight from the VBIOS ucNumEntries (u8, 0-255) with no clamp (process_pptables_v1_0.c:708), so count>8 overflows VceLevel[] into the following fields of SMU74_Discrete_DpmTable (and, for the smc_state_table, into polaris10_smumgr fields such as power_tune_defaults which is later dereferenced). polaris10_populate_smc_uvd_level() has the identical flaw for UvdLevel[SMU74_MAX_LEVELS_UVD=8] at :1404-1407.

### Can it be reproduced on this guest? — NO (hardware-gated)
Requires an AMD Polaris10 GPU with amdgpu attached whose VBIOS MM-dependency table has ucNumEntries > 8 (crafted VBIOS via passthrough/hotplug). Reached during powerplay init. QEMU audit guest has no AMD GPU, no /dev/dri, amdgpu.ko not loaded => unreachable here.

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 `amdgpu` 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 `amdgpu` 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
Clamp the count to the fixed array size using the same ternary already used elsewhere in this file for the pcie-link levels (~:2191): `VceLevelCount = (uint8_t)((SMU74_MAX_LEVELS_VCE < mm_table->count) ? SMU74_MAX_LEVELS_VCE : mm_table->count)` and the analogous line for UvdLevelCount/SMU74_MAX_LEVELS_UVD. Supersedes the finding proposal (clamp count to SMU74_MAX_LEVELS_*).

The fix was applied to in-guest `/usr/src` (all hunks applied cleanly) and the `amdgpu` module was
rebuilt with the kernel's `-Werror` flags:
`cd /usr/src/sys/dev/...amdgpu... && 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.
