Skip to contentSkip to conversation

CVE-2024-56695: drm/amdkfd: Use dynamic allocation for CU occupancy array in 'kfd_get_cu_occupancy()'

DISCUSSION Greg Kroah-Hartman 1 participant 1 message Dec 28, 2024

lore
Share & tools
lore
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

drm/amdkfd: Use dynamic allocation for CU occupancy array in 'kfd_get_cu_occupancy()'

The kfd_get_cu_occupancy function previously declared a large cu_occupancy array as a local variable, which could lead to stack overflows due to excessive stack usage. This commit replaces the static array allocation with dynamic memory allocation using kcalloc, thereby reducing the stack size.

This change avoids the risk of stack overflows in kernel space, in scenarios where AMDGPU_MAX_QUEUES is large. The allocated memory is freed using kfree before the function returns to prevent memory leaks.

Fixes the below with gcc W=1:
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c: In function ‘kfd_get_cu_occupancy’:
drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:322:1: warning: the frame size of 1056 bytes is larger than 1024 bytes [-Wframe-larger-than=]
322 | }

      | ^

The Linux kernel CVE team has assigned CVE-2024-56695 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 6.12 with commit 6ae9e1aba97e4cdaa31a0bfdc07497ad0e915c84 and fixed in 6.12.2 with commit 6d9f07196389f35a3afebcf1a12c1425725caddd
	Issue introduced in 6.12 with commit 6ae9e1aba97e4cdaa31a0bfdc07497ad0e915c84 and fixed in 6.13-rc1 with commit 922f0e00017b09d9d47e3efac008c8b20ed546a0

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2024-56695

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
drivers/gpu/drm/amd/amdkfd/kfd_process.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/6d9f07196389f35a3afebcf1a12c1425725caddd
	https://git.kernel.org/stable/c/922f0e00017b09d9d47e3efac008c8b20ed546a0