]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
drm/amdgpu: fix CPER ring header parsing
authorXiang Liu <xiang.liu@amd.com>
Thu, 9 Apr 2026 09:10:21 +0000 (17:10 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 17 Apr 2026 18:49:47 +0000 (14:49 -0400)
commitb8939bd764c9c8bf6488dc0d71d9c718c25d8cfc
treeec20cae520f062a331b849b45d6f91d29fbff111
parentd42d3012b278151b65bb8e328bbc6fdc678822a4
drm/amdgpu: fix CPER ring header parsing

amdgpu_cper_ring_get_ent_sz() parses CPER headers directly from the
circular ring buffer to determine the current entry size. When the ring
is full and the write pointer lands near the end of the buffer, the
header can wrap across the ring boundary.

The existing code treats the 4-byte CPER signature as a C string and
uses strcmp() on in-ring binary data, then reads record_length through a
direct struct pointer cast. Both assumptions are unsafe for wrapped
entries and can read past the end of the ring mapping.

Fix the parser by comparing the signature as raw bytes and by copying
the header into a local buffer before reading record_length, handling
wraparound explicitly in both cases. This avoids out-of-bounds reads in
amdgpu_cper_ring_get_ent_sz() when the CPER ring is full or the current
entry starts at the tail of the ring.

Signed-off-by: Xiang Liu <xiang.liu@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cper.c