β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-1467

vi_get_register_value OOB read of gfx.config.rb_config[se][sh] via AMDGPU_INFO_READ_MMR_REG (DF-1403 twin)

Summary

vi_get_register_value at vi.c:550-568: se_idx/sh_idx from user ioctl AMDGPU_INFO_READ_MMR_REG (masked 0xff each, 0-254). rb_config[AMDGPU_GFX_MAX_SE=4][AMDGPU_GFX_MAX_SH_PER_SE=2]. No bounds check. se>=4 or sh>=2 -> OOB read of ~12KB past array into amdgpu_gfx struct (kernel pointers). DRM_AUTH|DRM_RENDER_ALLOW (unprivileged). VI-class HW (Topaz/Fiji/Tonga/Polaris/Carrizo/Stoney). Twin of DF-1403 (cik.c). Fix: check se_idx<AMDGPU_GFX_MAX_SE && sh_idx<AMDGPU_GFX_MAX_SH_PER_SE.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1467 Β· 10 files
FileTypeDescriptionSize
README.md readme human-readable summary 1.9 KB ↓ raw
VERDICT.md verdict full source-level analysis + fix-validation result 2.9 KB ↓ raw
fix.diff suggested-fix git-apply-able minimal fix; compiles -Werror clean 507 B view raw
build.sh build-script echoes the module/kernel rebuild command 384 B view raw
run.sh run-script no live trigger on this guest 288 B view raw
env.txt environment guest uname, modules loaded, HW-gated note 344 B view raw
build.log build-log kernel build log excerpt proving -Werror clean compile of patched source 378 B view raw
fix_apply.log apply-log patch --dry-run output proving fix.diff applies cleanly on with-src 345 B view raw
../fix_build_combined.log build-log Combined 41-finding kernel build (rc=0, -Werror clean) 5.6 MB ↓ download
../fix_build_summary.txt build-summary Summary of the combined 41-finding kernel build 826 B view raw
README.md readme human-readable summary
↓ download raw

PoC DF-1467: vi_get_register_value OOB read of rb_config[se][sh]

Class: kernel struct OOB read (info leak) Cited site: sys/dev/drm/amd/amdgpu/vi.c:550-568

Reproduction status

HW/module gated β€” cannot be live-triggered on the audit QEMU guest.

No β€” amdgpu is a loadable module and only attaches to AMD GPUs (Tonga/Fiji/Polaris etc.). No AMD GPU in the audit guest. Trigger is AMDGPU_INFO_READ_MMR_REG ioctl with se/sh in 0..254 (the masked range excludes only 0xff).

The bug is confirmed at the source level by tracing the cited path:line in sys/dev/drm/amd/amdgpu/vi.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

vi.c:556-557 se_idx = se_num==0xffffffff ? 0 : se_num; sh_idx = ...; where se_num/sh_num come from user ioctl masked to 0..254 (amdgpu_kms.c:654-659). Lines 561-567 index adev->gfx.config.rb_config[se_idx][sh_idx] which is sized [AMDGPU_GFX_MAX_SE=4][AMDGPU_GFX_MAX_SH_PER_SE=2] (amdgpu_gfx.h:179). se_idx>=4 or sh_idx>=2 reads ~12KB past the array into the amdgpu_gfx struct (kernel pointers). DRM_AUTH|DRM_RENDER_ALLOW gated but reachable by any DRM client.

Realistic impact ceiling

leak (info leak, KASLR bypass)

Fix

Add if (se_idx >= AMDGPU_GFX_MAX_SE || sh_idx >= AMDGPU_GFX_MAX_SH_PER_SE) return 0; before the switch.

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

How to validate the fix

# 1. Apply fix.diff against the in-guest source:
scp -F dfbsd-qemu/config fix.diff dfbsd:/root/DF-1467.diff
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src && patch -p1 < /root/DF-1467.diff'

# 2. Rebuild the affected module (preferred) or a single-fix kernel:
ssh -F dfbsd-qemu/config dfbsd 'cd /usr/src/sys/sys/dev/drm/amd/amdgpu && make'

# 3. The compile must succeed with -Werror (it does β€” see build.log).
VERDICT.md verdict full source-level analysis + fix-validation result
↓ download raw

VERDICT β€” DF-1467: vi_get_register_value OOB read of rb_config[se][sh]

Verdict

INCONCLUSIVE (HW/module gated) β€” source-level confirmed, fix validated.

The bug is real and present in master DEV source at sys/dev/drm/amd/amdgpu/vi.c:550-568, but the affected driver attaches only to hardware not present in the audit QEMU guest, so it cannot be live-triggered here. The fix.diff applies cleanly and compiles with -Werror (kernel build rc=0; see fix_build.log).

Mechanism (cited path β†’ primitive β†’ effect)

vi.c:556-557 se_idx = se_num==0xffffffff ? 0 : se_num; sh_idx = ...; where se_num/sh_num come from user ioctl masked to 0..254 (amdgpu_kms.c:654-659). Lines 561-567 index adev->gfx.config.rb_config[se_idx][sh_idx] which is sized [AMDGPU_GFX_MAX_SE=4][AMDGPU_GFX_MAX_SH_PER_SE=2] (amdgpu_gfx.h:179). se_idx>=4 or sh_idx>=2 reads ~12KB past the array into the amdgpu_gfx struct (kernel pointers). DRM_AUTH|DRM_RENDER_ALLOW gated but reachable by any DRM client.

Reachability on this guest

No β€” amdgpu is a loadable module and only attaches to AMD GPUs (Tonga/Fiji/Polaris etc.). No AMD GPU in the audit guest. Trigger is AMDGPU_INFO_READ_MMR_REG ioctl with se/sh in 0..254 (the masked range excludes only 0xff).

Phase 6 β€” escalation potential

This is a kernel struct OOB read (info leak) 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).

For findings in this batch that are corruption-class on hardware they would be live-tested on (NIC cards, RAID HBAs, AMD/Intel GPUs), the realistic escalation ceiling is documented per finding (info-leak vs DoS vs latent privesc). No uid=0 claim is made β€” none is reachable on this guest.

Phase 8 β€” fix validation

fix.diff is a minimal, targeted fix at the root cause confirmed above.

  • Applied cleanly with patch -p1 --forward (verified in fix_apply.log).
  • Compiled with -Werror as part of make -j6 nativekernel KERNCONF=X86_64_GENERIC (kernel build rc=0; affected module builds radeon.ko/amdgpu.ko/sound.ko/i915.ko/vga_switcheroo.ko all produced).
  • For musycc.c (not in any default config) the file was compiled standalone with the kernel -Werror cflags β€” rc=0.

Add if (se_idx >= AMDGPU_GFX_MAX_SE || sh_idx >= AMDGPU_GFX_MAX_SH_PER_SE) return 0; before the switch.

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

Detail

Exploit chain

none β€” amdgpu HW-gated (no AMD GPU in guest). Primitive is info-leak (KASLR bypass) on real HW; no live escalation possible on this guest.

Evidence (decisive lines)

Source-level confirmation at sys/dev/drm/amd/amdgpu/vi.c:556, sys/dev/drm/amd/amdgpu/vi.c:561, sys/dev/drm/amd/amdgpu/amdgpu_gfx.h:179. fix.diff applies cleanly (patch -p1 --forward: APPLIES_OK) and compiles -Werror clean as part of `make -j6 nativekernel KERNCONF=X86_64_GENERIC` (rc=0; affected .o/.ko produced). No live trigger on this guest (HW/module gated).

PoC changes

Wrote VERDICT.md, fix.diff (one hunk: bounds check returning 0), build/run.sh, build.log excerpt, fix_apply.log, env.txt, manifest.json.

Verified recommended fix

Add if (se_idx >= AMDGPU_GFX_MAX_SE || sh_idx >= AMDGPU_GFX_MAX_SH_PER_SE) return 0; before the switch at vi.c:559. Supersedes any pre-verification proposal. The full git-apply-able diff lives in findings/poc/DF-1467/fix.diff.

Verdict

vi_get_register_value (550-568): se_idx/sh_idx from AMDGPU_INFO_READ_MMR_REG masked to 0..254 (amdgpu_kms.c:654-659; 0xff becomes 0xffffffff sentinel). Lines 561-567 index adev->gfx.config.rb_config[se_idx][sh_idx] sized [AMDGPU_GFX_MAX_SE=4][AMDGPU_GFX_MAX_SH_PER_SE=2] (amdgpu_gfx.h:179). se_idx>=4 or sh_idx>=2 reads ~12KB past the array into amdgpu_gfx struct (kernel pointers) β†’ info leak. amdgpu is a loadable module attaching only to AMD GPUs β€” not present in the audit guest. Source-level confirmed.