Patch "drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode()" has been added to the 6.9-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode()

to the 6.9-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     drm-amdgpu-fix-buffer-size-in-gfx_v9_4_3_init_-cp_co.patch
and it can be found in the queue-6.9 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 369bb24905e71127f827facbae8af8707fe936bb
Author: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx>
Date:   Thu Apr 25 11:22:32 2024 +0530

    drm/amdgpu: Fix buffer size in gfx_v9_4_3_init_ cp_compute_microcode() and rlc_microcode()
    
    [ Upstream commit acce6479e30f73ab0872e93a75aed1fb791d04ec ]
    
    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);
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Fixes: 86301129698b ("drm/amdgpu: split gc v9_4_3 functionality from gc v9_0")
    Cc: Hawking Zhang <Hawking.Zhang@xxxxxxx>
    Cc: Christian König <christian.koenig@xxxxxxx>
    Cc: Alex Deucher <alexander.deucher@xxxxxxx>
    Cc: Lijo Lazar <lijo.lazar@xxxxxxx>
    Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx>
    Suggested-by: Lijo Lazar <lijo.lazar@xxxxxxx>
    Reviewed-by: Lijo Lazar <lijo.lazar@xxxxxxx>
    Signed-off-by: Alex Deucher <alexander.deucher@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
index f4d48d6d7e777..d89d6829f1df4 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c
@@ -431,7 +431,7 @@ static int gfx_v9_4_3_init_cp_compute_microcode(struct amdgpu_device *adev,
 
 static int gfx_v9_4_3_init_microcode(struct amdgpu_device *adev)
 {
-	char ucode_prefix[30];
+	char ucode_prefix[15];
 	int r;
 
 	amdgpu_ucode_ip_version_decode(adev, GC_HWIP, ucode_prefix, sizeof(ucode_prefix));




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux