Patch "drm/amdgpu: Fix snprintf usage in amdgpu_gfx_kiq_init_ring" has been added to the 6.10-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 snprintf usage in amdgpu_gfx_kiq_init_ring

to the 6.10-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-snprintf-usage-in-amdgpu_gfx_kiq_init.patch
and it can be found in the queue-6.10 subdirectory.

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



commit 2e91780a79761a8a34d1eb18c7348c70d05ec905
Author: Srinivasan Shanmugam <srinivasan.shanmugam@xxxxxxx>
Date:   Tue May 21 10:03:37 2024 +0530

    drm/amdgpu: Fix snprintf usage in amdgpu_gfx_kiq_init_ring
    
    [ Upstream commit 0ea55445554209913a72eab86b60f5788776c4d6 ]
    
    This commit fixes a format truncation issue arosed by the snprintf
    function potentially writing more characters into the ring->name buffer
    than it can hold, in the amdgpu_gfx_kiq_init_ring function
    
    The issue occurred because the '%d' format specifier could write between
    1 and 10 bytes into a region of size between 0 and 8, depending on the
    values of xcc_id, ring->me, ring->pipe, and ring->queue. The snprintf
    function could output between 12 and 41 bytes into a destination of size
    16, leading to potential truncation.
    
    To resolve this, the snprintf line was modified to use the '%hhu' format
    specifier for xcc_id, ring->me, ring->pipe, and ring->queue. The '%hhu'
    specifier is used for unsigned char variables and ensures that these
    values are printed as unsigned decimal integers.
    
    Fixes the below with gcc W=1:
    drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c: In function ‘amdgpu_gfx_kiq_init_ring’:
    drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:61: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size between 0 and 8 [-Wformat-truncation=]
      332 |         snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
          |                                                             ^~
    drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:50: note: directive argument in the range [0, 2147483647]
      332 |         snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
          |                                                  ^~~~~~~~~~~~~~~~~
    drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c:332:9: note: ‘snprintf’ output between 12 and 41 bytes into a destination of size 16
      332 |         snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      333 |                  xcc_id, ring->me, ring->pipe, ring->queue);
          |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    Fixes: 345a36c4f1ba ("drm/amdgpu: prefer snprintf over sprintf")
    Cc: Alex Deucher <alexander.deucher@xxxxxxx>
    Cc: Christian König <christian.koenig@xxxxxxx>
    Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@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/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
index 1d955652f3ba6..2cb8ab86efae8 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
@@ -329,7 +329,7 @@ int amdgpu_gfx_kiq_init_ring(struct amdgpu_device *adev, int xcc_id)
 
 	ring->eop_gpu_addr = kiq->eop_gpu_addr;
 	ring->no_scheduler = true;
-	snprintf(ring->name, sizeof(ring->name), "kiq_%d.%d.%d.%d",
+	snprintf(ring->name, sizeof(ring->name), "kiq_%hhu.%hhu.%hhu.%hhu",
 		 xcc_id, ring->me, ring->pipe, ring->queue);
 	r = amdgpu_ring_init(adev, ring, 1024, irq, AMDGPU_CP_KIQ_IRQ_DRIVER0,
 			     AMDGPU_RING_PRIO_DEFAULT, NULL);




[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