Vulnerability · Published Jun 24, 2024 · Assigned by Linux

CVE-2024-39291drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode()

High 7.8

In plain English

A high-severity security flaw in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 16% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS NVD)7.8High
Exploit odds (30 days)0.2%top 84.4% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:13linux6.9.7-1DEBIAN-CVE-2024-39291
Debian:14linux6.9.7-1DEBIAN-CVE-2024-39291
Ubuntu:24.04:LTSlinux6.8.0-44.44UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-aws6.8.0-1015.16UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1015.16~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-azure6.8.0-1014.16UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1014.16~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-gcp6.8.0-1014.16UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-gcp-6.86.8.0-1014.16~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-gke6.8.0-1010.13UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-hwe-6.86.8.0-45.45~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-ibm6.8.0-1012.12UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-intel-iot-realtimeno fix listedUBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-44.44.1UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.86.8.0-44.44.1~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1013.14UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1013.14~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-nvidia-lowlatency6.8.0-1013.14.1UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1012.12UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-oracle6.8.0-1012.12UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1012.12~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-raspi6.8.0-1011.12UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2024-39291
Ubuntu:24.04:LTSlinux-riscv6.8.0-44.44.1UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-riscv-6.86.8.0-44.44.1~22.04.1UBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2024-39291
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2024-39291

Affected products (as reported)

VendorProductVersions
Linux Linux 86301129698be52f8398f92ea8564168f6bfcae1 – before 19bd9537b6bc1c882df25206c15917214d8e946086301129698be52f8398f92ea8564168f6bfcae1 – before f1b6a016dfa45cedc080d36fa5d6f22237d80e8b86301129698be52f8398f92ea8564168f6bfcae1 – before acce6479e30f73ab0872e93a75aed1fb791d04ec
Linux Linux 6.5

References