CVE-2024-39291·Kernel vulnerability
In the Linux kernel, the following vulnerability has been resolved: drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode() The function gfx_v9_4_3_init_microcode in gfx_v9_4_3.c was generating about potential truncation of output when using the snprintf function. The issue was due to the size of the buffer 'ucode_prefix' being too small to accommodate the maximum possible length of the string being written into it. The string being written is "amdgpu/%s_mec.bin" or "amdgpu/%s_rlc.bin", where %s is replaced by the value of 'chip_name'. The length of this string without the %s is 16 characters. The warning message indicated that 'chip_name' could be up to 29 characters long, resulting in a total of 45 characters, which exceeds the buffer size of 30 characters. To resolve this issue, the size of the 'ucode_prefix' buffer has been reduced from 30 to 15. This ensures that the maximum possible length of the string being written into the buffer will not exceed its size, thus preventing potential buffer overflow and truncation issues. Fixes the below with gcc W=1: drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c: In function ‘gfx_v9_4_3_early_init’: drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:379:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=] 379 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name); | ^~ ...... 439 | r = gfx_v9_4_3_init_rlc_microcode(adev, ucode_prefix); | ~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:379:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30 379 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", chip_name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:413:52: warning: ‘%s’ directive output may be truncated writing up to 29 bytes into a region of size 23 [-Wformat-truncation=] 413 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name); | ^~ ...... 443 | r = gfx_v9_4_3_init_cp_compute_microcode(adev, ucode_prefix); | ~~~~~~~~~~~~ drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c:413:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 30 413 | snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", chip_name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Severity
- high
- Software
- Kernel
- Fixed in
- 6.9.4
- Published
- 2024-06-24
Affected versions
From: 6.7
Until: 6.9.4
Fixed in: 6.9.4
How to fix this CVE
Update your Linux kernel to version 6.9.4 or later to patch a buffer size vulnerability in AMD GPU microcode initialization. This issue affects the gfx_v9_4_3 driver and could allow local privilege escalation through improper string handling in firmware loading functions. Reboot your system after applying the kernel update to ensure the patched version is active.
sudo dnf install kernel kernel-devel && sudo rebootDefensia detects this vulnerability
How to check if you are affected
- Check installed kernel version: uname -r
- Verify if AMD GPU (amdgpu) driver is loaded: lsmod | grep amdgpu
- Confirm if gfx_v9_4_3 is your GPU variant: grep -i 'gfx_v9_4_3' /var/log/dmesg or dmesg | grep amdgpu
- Verify the fix: Compare your kernel version against 6.9.4 using uname -r, ensuring it is 6.9.4 or newer
FAQ
What is CVE-2024-39291?
This vulnerability is a buffer size miscalculation in the AMD GPU (amdgpu) kernel driver's microcode initialization routine. A locally authenticated attacker could potentially cause memory corruption or privilege escalation by exploiting improper string handling when loading firmware files.
Is CVE-2024-39291 being actively exploited?
No, this vulnerability is not listed in CISA's Known Exploited Vulnerabilities (KEV) catalog and has no publicly available exploits at this time.
What versions of Kernel are affected by CVE-2024-39291?
Linux kernel versions 6.7 through 6.9.3 are vulnerable. The issue is resolved in kernel version 6.9.4 and later.
How do I check if my server is vulnerable to CVE-2024-39291?
Run uname -r to check your kernel version. If it reports a version between 6.7 and 6.9.3 inclusive, and you have AMD GPU hardware with amdgpu driver loaded (verify with lsmod | grep amdgpu), your system is vulnerable.
Does Defensia detect CVE-2024-39291?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If Kernel is installed on a monitored server, CVE-2024-39291 will appear in your dashboard with remediation steps.
Related Kernel CVEs
References
- https://git.kernel.org/stable/c/19bd9537b6bc1c882df25206c15917214d8e9460
- https://git.kernel.org/stable/c/acce6479e30f73ab0872e93a75aed1fb791d04ec
- https://git.kernel.org/stable/c/f1b6a016dfa45cedc080d36fa5d6f22237d80e8b
- https://git.kernel.org/stable/c/19bd9537b6bc1c882df25206c15917214d8e9460
- https://git.kernel.org/stable/c/acce6479e30f73ab0872e93a75aed1fb791d04ec
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-39291. Free for 1 server.
Get started free