mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-07 10:29:52 +00:00
drm/amdkfd: Fix out-of-bounds read in kdf_create_vcrat_image_cpu()
[ Upstream commit8b335bff64] KASAN reported a slab-out-of-bounds read of size 1 in kdf_create_vcrat_image_cpu(). This occurs when, for example, when on an x86_64 with a single NUMA node because kfd_fill_iolink_info_for_cpu() is a no-op, but afterwards the sub_type_hdr->length, which is out-of-bounds, is read and multiplied by entries. Fortunately, entries is 0 in this case so the overall crat_table->length is still correct. Check if there were any entries before de-referencing sub_type_hdr which may be pointing to out-of-bounds memory. Fixes:b7b6c38529("drm/amdkfd: Calculate CPU VCRAT size dynamically (v2)") Suggested-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Jeremy Cline <jcline@redhat.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
ef9eb913c0
commit
eb8ca93e49
@@ -1034,11 +1034,14 @@ static int kfd_create_vcrat_image_cpu(void *pcrat_image, size_t *size)
|
|||||||
(struct crat_subtype_iolink *)sub_type_hdr);
|
(struct crat_subtype_iolink *)sub_type_hdr);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
crat_table->length += (sub_type_hdr->length * entries);
|
|
||||||
crat_table->total_entries += entries;
|
|
||||||
|
|
||||||
sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
|
if (entries) {
|
||||||
sub_type_hdr->length * entries);
|
crat_table->length += (sub_type_hdr->length * entries);
|
||||||
|
crat_table->total_entries += entries;
|
||||||
|
|
||||||
|
sub_type_hdr = (typeof(sub_type_hdr))((char *)sub_type_hdr +
|
||||||
|
sub_type_hdr->length * entries);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
pr_info("IO link not available for non x86 platforms\n");
|
pr_info("IO link not available for non x86 platforms\n");
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user