Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64AB71411C1 for ; Mon, 24 Jun 2024 13:52:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719237157; cv=none; b=nwwKbqTbAKAeCKAx6s3/8vWZ7OtWQxJJZBIX/1/rtQSiKAI7ZKjOI7L5icpoZtpkp8yyQHvRQ7Yrjiili33qWnT9swqtHbwbWXk+Sy6WCT0ygn53ZybppoYQOhQbI+dGHNsmoibL1EJmiMcMslcIUo+ndRgwIGlMhlkbbadAgY0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719237157; c=relaxed/simple; bh=pGmRZG4NItiBXJ9tkJIE/iBkoMmps2kwO9d+jXic61k=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=KEby1pYSQwhoInY3lh/kNfexAXJvUEJrZ+wvOWhHchqFzwgFiI64QtIgmLX/cxsWSm3HVcg6qSJj89FzBorWnxjxTXC5rEKU7O3cjM4zRCeE7T9HQb1qT7GrcGOnT8hJ/Uasa2HmAj1aJSnzCDnJEYOKuGq1ZUCQ6jtCumojhE8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ABUcu/NX; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ABUcu/NX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 778C8C2BBFC; Mon, 24 Jun 2024 13:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1719237156; bh=pGmRZG4NItiBXJ9tkJIE/iBkoMmps2kwO9d+jXic61k=; h=From:To:Cc:Subject:Date:Reply-to:From; b=ABUcu/NX6rFhiEWkAVX+t2Yto1m07MHVWYRpgelLnl0KNMZPMEnuIw7UpFd+g+MVL c7YP3+b4r7K5RNWaEGQf0emG7Pg1qoLQEjzS2Lmvo3tML7nC98CIr3Y7StnzM2wkmC zxs6kAaItdLfWhkrav5NcUkiGh9IUcS4RhcA0wPg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2024-39291: drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode() Date: Mon, 24 Jun 2024 15:52:32 +0200 Message-ID: <2024062432-CVE-2024-39291-be2c@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4477; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=pGmRZG4NItiBXJ9tkJIE/iBkoMmps2kwO9d+jXic61k=; b=owGbwMvMwCRo6H6F97bub03G02pJDGmVVQovXVevdo7jDDy9Is9owfPLC569WFwn/f/vpTsJy 7vSt3eIdMSyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEnj1hmGe9QsPc/sHvL9UT N2w0U7z9rn7XtrsMC7atPsnTLyKUZ8sRWHI/iiX62gmrlQA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The Linux kernel CVE team has assigned CVE-2024-39291 to this issue. Affected and fixed versions =========================== Issue introduced in 6.5 with commit 86301129698b and fixed in 6.6.33 with commit 19bd9537b6bc Issue introduced in 6.5 with commit 86301129698b and fixed in 6.9.4 with commit f1b6a016dfa4 Issue introduced in 6.5 with commit 86301129698b and fixed in 6.10-rc1 with commit acce6479e30f 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-39291 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/amdgpu/gfx_v9_4_3.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/19bd9537b6bc1c882df25206c15917214d8e9460 https://git.kernel.org/stable/c/f1b6a016dfa45cedc080d36fa5d6f22237d80e8b https://git.kernel.org/stable/c/acce6479e30f73ab0872e93a75aed1fb791d04ec