drm/amdgpu: bound SR-IOV RAS CPER dump parsing against used_size
authorChenglei Xie <Chenglei.Xie@amd.com>
Mon, 11 May 2026 19:24:29 +0000 (15:24 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 27 May 2026 14:48:27 +0000 (10:48 -0400)
commitebbd73d089bd47021e67a43bed665178adb55b4b
treec9e48b17c83d95e3718e86fd4dff328906c4a68b
parent2d071f6457af08f4692d340fcae030b5eabd6837
drm/amdgpu: bound SR-IOV RAS CPER dump parsing against used_size

The VF copies a PF-provided CPER telemetry blob and walks records using
cper_dump->count and each entry's record_length. count is u64 while the
loop used u32, so a large count could loop indefinitely. record_length was
not limited to the kmemdup'd region, so the first iteration could read far
past the allocation; record_length == 0 could spin forever on the same
entry. Together that allowed a malicious hypervisor to leak heap past the
blob into the CPER ring or hang the guest.

Require used_size to cover the fixed header before buf and stay within the
telemetry cap. Track remaining bytes in buf, cap iterations with u64 and
CPER_MAX_ALLOWED_COUNT, and reject record_length outside
[sizeof(cper_hdr), remaining] before writing to the ring.

Signed-off-by: Chenglei Xie <Chenglei.Xie@amd.com>
Reviewed-by: YiPeng Chai <YiPeng.Chai@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c