]> git.baikalelectronics.ru Git - kernel.git/commit
drm/amdkfd: Fix out-of-bounds read in kdf_create_vcrat_image_cpu()
authorJeremy Cline <jcline@redhat.com>
Mon, 11 Jan 2021 21:05:28 +0000 (16:05 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 14 Jan 2021 04:46:34 +0000 (23:46 -0500)
commit6e5f3b81760e1bafe30288c0b8dca30bd4224239
treed5964f13a008c06b419e05ccf11c14764825abdf
parent09d91bbc2d1ec9523530190c12f399a700c86083
drm/amdkfd: Fix out-of-bounds read in kdf_create_vcrat_image_cpu()

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: b7c5ed9a5ad5 ("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>
drivers/gpu/drm/amd/amdkfd/kfd_crat.c