Skip to contentSkip to conversation

drm/amdgpu: fix out of bounds access in gfx10 during ip dump

PATCH In review Sunil Khatri 2 participants 3 messages Jul 2, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: fix out of bounds access in gfx10 during ip dump

During ip dump in gfx10 the index variable is reused but is not reinitialized to 0 and this causes the index calculation to be wrong and access out of bound access.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -0
index 18488c02d1cf..a52c72739b40 100644
@@ -9287,6 +9287,7 @@ static void gfx_v10_ip_print(void *handle, struct drm_printer *p)
 	if (!adev->gfx.ip_dump_gfx_queues)
 		return;
 
+	index = 0;
 	reg_count = ARRAY_SIZE(gc_gfx_queue_reg_list_10);
 	drm_printf(p, "\nnum_me: %d num_pipe: %d num_queue: %d\n",
 		   adev->gfx.me.num_me,
@@ -9352,6 +9353,7 @@ static void gfx_v10_ip_dump(void *handle)
 	if (!adev->gfx.ip_dump_gfx_queues)
 		return;
 
+	index = 0;
 	reg_count = ARRAY_SIZE(gc_gfx_queue_reg_list_10);
 	amdgpu_gfx_off_ctrl(adev, false);
 	mutex_lock(&adev->srbm_mutex);
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 drm/amdgpu: fix out of bounds access in gfx11 during ip dump

During ip dump in gfx11 the index variable is reused but is not reinitialized to 0 and this causes the index calculation to be wrong and access out of bound access.

---
 drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +2 -0
index 0d078d0db162..b49e4e85bddf 100644
@@ -6401,6 +6401,7 @@ static void gfx_v11_ip_print(void *handle, struct drm_printer *p)
 	if (!adev->gfx.ip_dump_gfx_queues)
 		return;
 
+	index = 0;
 	reg_count = ARRAY_SIZE(gc_gfx_queue_reg_list_11);
 	drm_printf(p, "\nnum_me: %d num_pipe: %d num_queue: %d\n",
 		   adev->gfx.me.num_me,
@@ -6465,6 +6466,7 @@ static void gfx_v11_ip_dump(void *handle)
 	if (!adev->gfx.ip_dump_gfx_queues)
 		return;
 
+	index = 0;
 	reg_count = ARRAY_SIZE(gc_gfx_queue_reg_list_11);
 	amdgpu_gfx_off_ctrl(adev, false);
 	mutex_lock(&adev->srbm_mutex);
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/2
#2 lore raw
In reply to Sunil Khatri

Am 02.07.24 um 10:26 schrieb Sunil Khatri:

Quoted 3 lines

During ip dump in gfx10 the index variable is reused but is not reinitialized to 0 and this causes the index calculation to be wrong and access out of bound access.

Regards,
Christian.

Quoted 26 lines
---
  drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c | 2 ++
  1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +2 -0
index 18488c02d1cf..a52c72739b40 100644
@@ -9287,6 +9287,7 @@ static void gfx_v10_ip_print(void *handle, struct drm_printer *p)
  	if (!adev->gfx.ip_dump_gfx_queues)
  		return;
 
+	index = 0;
  	reg_count = ARRAY_SIZE(gc_gfx_queue_reg_list_10);
  	drm_printf(p, "\nnum_me: %d num_pipe: %d num_queue: %d\n",
  		   adev->gfx.me.num_me,
@@ -9352,6 +9353,7 @@ static void gfx_v10_ip_dump(void *handle)
  	if (!adev->gfx.ip_dump_gfx_queues)
  		return;
 
+	index = 0;
  	reg_count = ARRAY_SIZE(gc_gfx_queue_reg_list_10);
  	amdgpu_gfx_off_ctrl(adev, false);
  	mutex_lock(&adev->srbm_mutex);