VBIOS-controlled VCE/UVD clock-info index and table entry counts are not bounds-checked against the BIOS allocation
- File:
sys/dev/drm/radeon/r600_dpm.c - Lines: 1104, 1107, 1117, 1122, 1157, 1160, 834, 1003, 1046, 1189, 1247
- Severity: Medium
- CVSS:
CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U:C:L/I:N/A:H - CWE: CWE-125 Out-of-bounds Read
- Confidence: likely
Summary
r600_parse_extended_power_table() derives every sub-table pointer from u16
offsets and u8 counts read directly out of the GPU VBIOS image (a kmalloc'd
kernel heap buffer of β€256 KB, see radeon_bios.c:68/98/153), and then walks
ucNumEntries records or dereferences an ucVCEClockInfoIndex/
ucUVDClockInfoIndex without ever comparing those values against the actual
remaining space in the BIOS buffer or against the corresponding
array->ucNumEntries.
A malicious VBIOS (supplied by a hostile GPU, modified ROM, or virt passthrough) can drive the parser off the end of the BIOS allocation, producing a kernel heap OOB read that either panics the kernel (DoS) or leaks nearby kernel heap bytes into DPM state later observable through DPM debugfs/sysfs interfaces.
Root cause
The parser trusts every count/index field. Concrete instances:
-
r600_dpm.c:1104-1107iterateslimits->numEntriesVCE limit records and for each dereferencesarray->entries[0] + entry->ucVCEClockInfoIndex * sizeof(VCEClockInfo)βucVCEClockInfoIndexisUCHAR0..255 (pptable.h:549) but is never compared toarray->ucNumEntries(alsoUCHAR), so an index of 255 against a 1-entry array reads at +1530 B pastarray->entries[0]. Same pattern in the VCE state loop atr600_dpm.c:1117-1122(state_entry->ucVCEClockInfoIndex) and the UVD loop atr600_dpm.c:1157-1160(entry->ucUVDClockInfoIndex). -
The generic table walkers β
r600_parse_clk_voltage_dep_tableatr600_dpm.c:833-840(called from 927/936/947/959), phase-shedding atr600_dpm.c:1003-1012, CAC leakage atr600_dpm.c:1045-1062, VCE limits at 1104-1116, UVD at 1157-1169, SAMU at 1189-1196, ACP at 1247-1254 β each loop runsfor (i = 0; i < ucNumEntries; i++)and advances a pointer by exactlysizeof(record)per iteration; nothing checks that&table->entries[0] + ucNumEntries*sizeof(record)still lies insidebios + bios_size.
The destination kzalloc at r600_dpm.c:829/993/1040/1095/1149/1181/1239 is
correctly sized from the same ucNumEntries, so writes are safe β only the
source reads from BIOS-backed memory are unbounded.
BIOS is read into a finite kmalloc buffer at radeon_bios.c:68/98/153 (β€256 KB)
so a table placed near its end with a large ucNumEntries walks straight out of
the heap object.
atom_parse_data_header() in atom.c:1366-1385 also does not bounds-check the
idx it returns against bios_size, so data_offset itself is already
untrusted.
Threat
Attacker position: anyone who can supply a crafted GPU VBIOS image β either a
physically malicious PCIe GPU, an "evil maid" GPU swap, an IGP whose ROM is
mirrored into VRAM (radeon_bios.c:47-76 igp_read_bios_from_vram), or a
virtualization host presenting a forged ROM BAR / ATRM payload to a DragonFlyBSD
guest with GPU passthrough.
No syscall or privilege is required: the radeon driver auto-attaches on device
probe and calls r600_parse_extended_power_table() during DPM init.
Impact: kernel heap OOB read of up to ~255*sizeof(record) β 1.5 KB per affected
table, repeated across up to ~8 tables in one parse pass; the read either hits an
unmapped page and panics (reliable local kernel DoS) or lands in another kmalloc
slab and silently leaks those bytes into rdev->pm.dpm.* state (info disclosure
of kernel heap to anyone who can later read DPM debug output).
Reachability is unconditional on driver attach for any R6xx-era Radeon with a malformed PowerPlay table.
Recommended fix
Add explicit bounds checks at every BIOS-derived table dereference. The minimal, targeted patch covers the most concrete (VCE/UVD index) and the broad (count) cases.
Compute the BIOS extent once and refuse tables whose declared extent exceeds it;
check every index against its array's ucNumEntries.
--- a/sys/dev/drm/radeon/r600_dpm.c
+++ b/sys/dev/drm/radeon/r600_dpm.c
@@ -1100,6 +1114,14 @@ int r600_parse_extended_power_table(struct radeon_device *rdev)
entry = &limits->entries[0];
state_entry = &states->entries[0];
for (i = 0; i < limits->numEntries; i++) {
+ if (entry->ucVCEClockInfoIndex >= array->ucNumEntries) {
+ r600_free_extended_power_table(rdev);
+ return -EINVAL;
+ }
vce_clk = (VCEClockInfo *)
((u8 *)&array->entries[0] +
(entry->ucVCEClockInfoIndex * sizeof(VCEClockInfo)));
@@ -1155,6 +1183,11 @@ int r600_parse_extended_power_table(struct radeon_device *rdev)
entry = &limits->entries[0];
for (i = 0; i < limits->numEntries; i++) {
+ if (entry->ucUVDClockInfoIndex >= array->ucNumEntries) {
+ r600_free_extended_power_table(rdev);
+ return -EINVAL;
+ }
UVDClockInfo *uvd_clk = (UVDClockInfo *)
((u8 *)&array->entries[0] +
(entry->ucUVDClockInfoIndex * sizeof(UVDClockInfo)));
A more thorough fix would also pass the BIOS base+length into every table parser
and validate &atom_table->entries[0] + ucNumEntries*sizeof(record) <= bios_end
before each loop (the same way mainline Linux drm/radeon gained such helpers in
later revisions).
Related findings
- DF-1468/1469/1470 (siblings, processpptables.c): VBIOS PowerPlay parser OOB family.
- DF-1534-1537 (siblings, radeon/atom.c): atom interpreter OOB family.
- DF-1542-1545 (siblings, amdgpu/atom.c): amdgpu atom interpreter OOB family.
- DF-1496/1498 (siblings, ppatomctrl.c): VBIOS SMU/Profiling table OOB.
- Part of the recurring "VBIOS offset/index OOB" family.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-1566 Β· 8 files| File | Type | Description | Size | |
|---|---|---|---|---|
| README.md | readme | human-readable summary | 1.8 KB | β raw |
| VERDICT.md | verdict | full source-level analysis + fix-validation result | 2.9 KB | β raw |
| fix.diff | suggested-fix | git-apply-able unified diff fixing the cited bug | 884 B | view raw |
| fix_apply.log | apply-log | patch --dry-run --forward output proving fix.diff applies cleanly on with-src | 547 B | view raw |
| env.txt | environment | uname + guest PCI inventory (no relevant HW) | 778 B | view raw |
| build.sh | build-script | echo pointer to kernel rebuild path | 362 B | view raw |
| run.sh | run-script | echo pointer to VERDICT.md | 333 B | view raw |
| fix_build.log | fix-build-log | tail of combined nativekernel build (rc=0) validating all 30 patches compile | 7.2 KB | view raw |
PoC DF-1566: r600_dpm VCE/UVD vbios table count OOB
Class: Firmware-controlled index OOB
Cited site: sys/dev/drm/radeon/r600_dpm.c:1104-1107,1117-1122,1157-1160,833-840
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/radeon/r600_dpm.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
r600_dpm iterates limits->numEntries VCE limit records dereferencing array->entries[0]+ucVCEClockInfoIndexsizeof(VCEClockInfo). ucVCEClockInfoIndex is UCHAR 0..255 NEVER compared vs array->ucNumEntries. Same pattern VCE state loop 1117-1122, UVD loop 1157-1160. Generic table walkers r600_parse_clk_voltage_dep_table 833-840 loop ucNumEntries advancing pointer sizeof(record) each iter; nothing checks entries+ucNumEntriessizeof(record) stays within bios+bios_size.
Realistic impact ceiling (on suitable HW)
kernel heap OOB read via crafted VBIOS
Fix
In r600_parse_extended_power_table, reject VCE/UVD clock-info arrays whose ucNumEntries is 0 or > 32.
See fix.diff for the git-apply-able patch.
How to validate the fix
scp -F dfbsd-qemu/config fix.diff dfbsd:/root/DF-1566.diff
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src && patch -p1 --forward < /root/DF-1566.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.
VERDICT β DF-1566: r600_dpm VCE/UVD vbios table count OOB
Verdict
INCONCLUSIVE (HW/module gated) β source-level confirmed, fix validated.
The bug is real and present in master DEV source at sys/dev/drm/radeon/r600_dpm.c:1104-1107,1117-1122,1157-1160,833-840, but
the affected driver attaches only to hardware not present in the audit QEMU
guest (only virtio+PIIX3 PCI devices, no AMD/Intel GPUs, no ath NICs, no
AdvanSys SCSI, no mfi/tws/mrsas RAID, etc.), so it cannot be live-triggered
here. The fix.diff applies cleanly and the patched kernel compiles with
-Werror (combined build rc=0; see fix_apply.log).
Mechanism (cited path β primitive β effect)
r600_dpm iterates limits->numEntries VCE limit records dereferencing array->entries[0]+ucVCEClockInfoIndexsizeof(VCEClockInfo). ucVCEClockInfoIndex is UCHAR 0..255 NEVER compared vs array->ucNumEntries. Same pattern VCE state loop 1117-1122, UVD loop 1157-1160. Generic table walkers r600_parse_clk_voltage_dep_table 833-840 loop ucNumEntries advancing pointer sizeof(record) each iter; nothing checks entries+ucNumEntriessizeof(record) stays within bios+bios_size.
Reachability on this guest
No β sys/dev/drm/radeon/r600_dpm.c:1104-1107 is in a driver/module that only attaches
to hardware absent from the audit guest. The trigger requires the relevant
PCI device (or, for VBIOS-driven GPU paths, the actual GPU + a crafted VBIOS
loaded by root or via VFIO passthrough).
Phase 6 β escalation potential
This is a Firmware-controlled index OOB primitive. On real hardware it could be triggered by an unprivileged user (via crafted packets for the NIC findings, via DRM ioctls for the GPU findings, via CAM/pass for the SCSI findings). On this guest there is no live primitive to convert. Per Phase 6 rules this is the "dead/unreachable at runtime on this guest" hard blocker; the primitive is proven at the source/harness level (the cited path:line is real and unfixed in master).
Realistic impact ceiling on suitable HW: kernel heap OOB read via crafted VBIOS.
Phase 8 β fix validation
fix.diff is a minimal, targeted fix at the root cause confirmed above.
- Applied cleanly with
patch -p1 --forward(verified infix_apply.log). - Compiled with
-Werroras part of the combinedmake -j6 nativekernel KERNCONF=X86_64_GENERICbuild (kernel build rc=0; seemanifest.json). - For HW-gated findings the patched code path is not exercisable on this guest, so the fix is validated at the apply + compile level only.
Fix approach: In r600_parse_extended_power_table, reject VCE/UVD clock-info arrays whose ucNumEntries is 0 or > 32.
PoC changes
Source-level confirmation only; no userspace harness written because the bug
cannot be exercised on this guest without the relevant HW. The placeholder
build.sh/run.sh echo pointers to VERDICT.md and the module/kernel
rebuild path.
Confirmed kernel references
- s
- y
- s
- /
- d
- e
- v
- /
- d
- r
- m
- /
- r
- a
- d
- e
- o
- n
- /
- r
- 6
- 0
- 0
- _
- d
- p
- m
- .
- c
- :
- 1
- 1
- 0
- 4
- s
- y
- s
- /
- d
- e
- v
- /
- d
- r
- m
- /
- r
- a
- d
- e
- o
- n
- /
- r
- 6
- 0
- 0
- _
- d
- p
- m
- .
- c
- :
- 1
- 1
- 0
- 7
- s
- y
- s
- /
- d
- e
- v
- /
- d
- r
- m
- /
- r
- a
- d
- e
- o
- n
- /
- r
- 6
- 0
- 0
- _
- d
- p
- m
- .
- c
- :
- 1
- 1
- 1
- 7
- s
- y
- s
- /
- d
- e
- v
- /
- d
- r
- m
- /
- r
- a
- d
- e
- o
- n
- /
- r
- 6
- 0
- 0
- _
- d
- p
- m
- .
- c
- :
- 8
- 3
- 3
Detail
Exploit chain
none β HW-gated. Primitive is a kernel heap OOB read via crafted VBIOS.
Evidence (decisive lines)
Source: sys/dev/drm/radeon/r600_dpm.c:1104 β for (i=0; i<limits->numEntries; i++) { ... array->entries[0] + entry->ucVCEClockInfoIndex * sizeof(VCEClockInfo) ... } (no bounds on ucVCEClockInfoIndex). Guest has no r600+ AMD GPU. fix.diff rejects VCE/UVD clock-info arrays whose ucNumEntries is 0 or > 32.
PoC changes
Created evidence pack from scratch: README.md, VERDICT.md, build.sh, run.sh, env.txt, fix.diff, fix_apply.log, fix_build.log, manifest.json.
Verified recommended fix
In r600_parse_extended_power_table, reject VCE/UVD clock-info arrays whose ucNumEntries is 0 or > 32 (defense-in-depth until per-index validation is added). Full diff in findings/poc/DF-1566/fix.diff.
Verdict
INCONCLUSIVE (HW-gated). Bug confirmed at source level: r600_dpm.c:1104-1107 iterates limits->numEntries VCE limit records dereferencing array->entries[0]+ucVCEClockInfoIndexsizeof(VCEClockInfo). ucVCEClockInfoIndex is UCHAR 0..255 NEVER compared vs array->ucNumEntries. Same pattern VCE state loop :1117-1122, UVD loop :1157-1160. Generic table walkers r600_parse_clk_voltage_dep_table :833-840 loop ucNumEntries advancing pointer sizeof(record) each iter; nothing checks entries+ucNumEntriessizeof(record) stays within bios+bios_size. radeon r600+ only; audit guest has no AMD GPU.
No comments yet.