drm/amdkfd: Add bounds check for CRAT subtype length
authorWilliam Palacek <William.Palacek@amd.com>
Mon, 6 Jul 2026 14:25:58 +0000 (10:25 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Jul 2026 23:58:55 +0000 (19:58 -0400)
commit6e7566ba4739dd573c331adde1c96690f7a567bd
treedac35bc1cf5ea2eee0e3fd7667b706b24ead5568
parent35699ae99deabdb9100c2e6b5365c996712846e7
drm/amdkfd: Add bounds check for CRAT subtype length

The CRAT parser validates that the subtype header fits within the image,
but does not verify that the advertised subtype length fits. A malformed
CRAT table with an oversized length field causes out-of-bounds reads when
kfd_parse_subtype() casts the header to specific subtype structures.

Add validation that sub_type_hdr + length does not exceed the image
boundary before parsing the subtype contents.

Signed-off-by: William Palacek <William.Palacek@amd.com>
Reviewed-by: Alysa Liu <Alysa.Liu@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 48e1d1e6e8798aef0312e68d8e586021b5b3cf4d)
Cc: stable@vger.kernel.org
drivers/gpu/drm/amd/amdkfd/kfd_crat.c