Skip to contentSkip to conversation

drm/amdgpu: add error handle to avoid out-of-bounds

PATCH In review Bob Zhou 3 participants 3 messages Apr 23, 2024 – Apr 24, 2024

Subsystems (2)
lore
Share & tools
lore

Bob Zhou

author
#0 lore raw

PATCH 1/1 drm/amdgpu: add error handle to avoid out-of-bounds

if the sdma_v4_0_irq_id_to_seq return -EINVAL, the process should be stop to avoid out-of-bounds read, so directly return -EINVAL.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3 -0
index e2e3856938ed..101038395c3b 100644
@@ -2021,6 +2021,9 @@ static int sdma_v4_0_process_trap_irq(struct amdgpu_device *adev,
 
 	DRM_DEBUG("IH: SDMA trap\n");
 	instance = sdma_v4_0_irq_id_to_seq(entry->client_id);
+	if (instance < 0)
+		return instance;
+
 	switch (entry->ring_id) {
 	case 0:
 		amdgpu_fence_process(&adev->sdma.instance[instance].ring);
Signature · 1 line
2.34.1
maintainer Acked-by on v1 1/1
#1 lore raw

Am 23.04.24 um 11:15 schrieb Bob Zhou:

Quoted 4 lines

if the sdma_v4_0_irq_id_to_seq return -EINVAL, the process should be stop to avoid out-of-bounds read, so directly return -EINVAL.

Quoted 18 lines
---
  drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 3 +++
  1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3 -0
index e2e3856938ed..101038395c3b 100644
@@ -2021,6 +2021,9 @@ static int sdma_v4_0_process_trap_irq(struct amdgpu_device *adev,
 
  	DRM_DEBUG("IH: SDMA trap\n");
  	instance = sdma_v4_0_irq_id_to_seq(entry->client_id);
+	if (instance < 0)
+		return instance;
+
  	switch (entry->ring_id) {
  	case 0:
  		amdgpu_fence_process(&adev->sdma.instance[instance].ring);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Bob Zhou

[AMD Official Use Only - General]

Thanks for catching. Please populate the fix to sdma_v4_4_2 as well if necessary.

Quoted 34 lines

-----Original Message-----
From: Bob Zhou <[email protected]>
Sent: Tuesday, April 23, 2024 5:15 PM
To: [email protected]; Ma, Le <[email protected]>
Cc: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Zhou, Bob <[email protected]>
Subject: [PATCH] drm/amdgpu: add error handle to avoid out-of-bounds

if the sdma_v4_0_irq_id_to_seq return -EINVAL, the process should be stop to avoid out-of-bounds read, so directly return -EINVAL.

---
 drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/sdma_v4_0.c +3 -0
index e2e3856938ed..101038395c3b 100644
@@ -2021,6 +2021,9 @@ static int sdma_v4_0_process_trap_irq(struct
 amdgpu_device *adev,
 
      DRM_DEBUG("IH: SDMA trap\n");
      instance = sdma_v4_0_irq_id_to_seq(entry->client_id);
+     if (instance < 0)
+             return instance;
+
      switch (entry->ring_id) {
      case 0:
              amdgpu_fence_process(&adev->sdma.instance[instance].ring);

--
2.34.1