FAILED: patch "[PATCH] drm/amdkfd: Add bounds check for CRAT subtype length" failed to apply to 7.1-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 7.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-7.1.y
git checkout FETCH_HEAD
git cherry-pick -x 6e7566ba4739dd573c331adde1c96690f7a567bd
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026080545-variable-gala-d869@gregkh' --subject-prefix 'PATCH 7.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 6e7566ba4739dd573c331adde1c96690f7a567bd Mon Sep 17 00:00:00 2001
From: William Palacek <[email protected]>
Date: Mon, 6 Jul 2026 10:25:58 -0400
Subject: [PATCH] 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.
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +9 -0
@@ -1412,6 +1412,15 @@ int kfd_parse_crat_table(void *crat_image, struct list_head *device_list,break ; } +/* Validate subtype fits within remaining image */ +if ((char *)sub_type_hdr + sub_type_hdr->length > + (char *)crat_image + image_len) { +pr_warn ("CRAT subtype length %u exceeds image bounds\n" , + sub_type_hdr->length); + ret = -EINVAL ; +break ; + } +if (sub_type_hdr->flags &CRAT_SUBTYPE_FLAGS_ENABLED ) { ret =kfd_parse_subtype (sub_type_hdr, device_list);if (ret)
Sasha Levin
maintainerPATCH 1/1 drm/amdkfd: Add bounds check for CRAT subtype length
From: William Palacek <[email protected]>
[ Upstream commit 6e7566ba4739dd573c331adde1c96690f7a567bd ]
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.
--- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +9 -0
@@ -1404,6 +1404,15 @@ int kfd_parse_crat_table(void *crat_image, struct list_head *device_list, sub_type_hdr = (struct crat_subtype_generic *)(crat_table+1 );while ((char *)sub_type_hdr +sizeof (struct crat_subtype_generic ) < ((char *)crat_image) + image_len) { +/* Validate subtype fits within remaining image */ +if ((char *)sub_type_hdr + sub_type_hdr->length > + (char *)crat_image + image_len) { +pr_warn ("CRAT subtype length %u exceeds image bounds\n" , + sub_type_hdr->length); + ret = -EINVAL ; +break ; + } +if (sub_type_hdr->flags &CRAT_SUBTYPE_FLAGS_ENABLED ) { ret =kfd_parse_subtype (sub_type_hdr, device_list);if (ret)
Signature · 1 line
2.53.0