Null Return of kmalloc_array() in drm/amdkfd
Summary
GSD-2022-1002461: drm/amdkfd: Check for potential null return of kmalloc_array(). Affects Kernel versions < 32cf90a521dcc0f136db7ee5ba32bfe5f79e460e. No fix is published. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The drm/amdkfd package is a component of the Linux Kernel that provides support for AMD GPUs in the kernel's Direct Rendering Manager (DRM) subsystem. It includes the AMD Kernel Fusion Driver (KFD) which enables Heterogeneous System Architecture (HSA) functionality. The package allows for efficient communication between the CPU and GPU, facilitating tasks such as parallel computing and GPU acceleration. However, a vulnerability has been identified in the package that could potentially lead to security issues.
Vulnerability Detail
The vulnerability in drm/amdkfd arises from a failure to check for a potential null return of kmalloc_array(). This function is used to allocate memory for an array of objects. If the allocation fails and returns null, subsequent operations relying on this memory can lead to unexpected behavior, including crashes or the execution of arbitrary code. Attackers may be able to exploit this vulnerability to gain unauthorized access, escalate privileges, or cause denial of service.
How To Fix
No fixed version is published for this vulnerability.
Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →
Workaround
As a workaround, users can apply the patch provided in the commit 32cf90a521dcc0f136db7ee5ba32bfe5f79e460e manually. The patch modifies the code in drm/amdkfd to include the necessary null return check for kmalloc_array(). Here is an example of the modified code:
// Original code
...
buffer = kmalloc_array(num_elements, sizeof(struct element), GFP_KERNEL);
...
// Modified code
...
buffer = kmalloc_array(num_elements, sizeof(struct element), GFP_KERNEL);
if (!buffer) {
// Handle allocation failure
return -ENOMEM;
}
...
Conclusion
The vulnerability in drm/amdkfd that fails to check for a potential null return of kmalloc_array() can lead to security issues, including unauthorized access, privilege escalation, or denial of service. It is crucial to update the Linux Kernel to version v4.9.311 or later, or apply the provided patch, to mitigate the risk. Users can also utilize the Vulert Playground at https://vulert.com/scanner to check if their system is affected by this vulnerability. For further support, please contact DevNack.com.
See every vulnerability recorded for Kernel →
FAQ
The vulnerability could potentially allow attackers to gain unauthorized access, escalate privileges, or cause denial of service. It is important to update the Linux Kernel to mitigate the risk.
You can use the Vulert Playground at Vulert Scanner to check if your system is affected by this vulnerability. Simply upload your package-lock.json file and the playground will analyze it for open-source vulnerabilities in real-time.
At the time of this report, no known exploits have been reported for this specific vulnerability. However, it is crucial to apply the recommended fix or workaround to prevent potential exploitation.
The vulnerability itself does not provide remote exploitation capabilities. However, if an attacker already has access to the affected system, they may be able to exploit the vulnerability to escalate privileges or perform other malicious actions.
For further support on vulnerability remediation, you can reach out to info@devnack.com. Our team will be happy to assist you in addressing any concerns or questions you may have.
Related vulnerabilities
Recent vulnerabilities recorded for Kernel.