Skip to contentSkip to conversation

drm/amdgpu: avoid out of bounds access on array interrupt_status_offsets

PATCH Superseded Colin King 2 participants 3 messages Sep 20, 2016

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drm/amdgpu: avoid out of bounds access on array interrupt_status_offsets

From: Colin Ian King <[email protected]>

The check for an out of bound index into array interrupt_status_offsets is off-by-one. Fix this and also don't compared to a hard coded array size but use ARRAY_SIZE instead.

---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -1
index d3512f3..4ce4c1a 100644
@@ -2782,7 +2782,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,
 	uint32_t disp_int, mask, int_control, tmp;
 	unsigned hpd;
 
-	if (entry->src_data > 6) {
+	if (entry->src_data >= ARRAY_SIZE(interrupt_status_offsets)) {
 		DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
 		return 0;
 	}
Signature · 1 line
2.9.3
#1 lore raw
Quoted 16 lines · Colin King

From: Colin Ian King <[email protected]>

The check for an out of bound index into array interrupt_status_offsets is off-by-one. Fix this and also don't compared to a hard coded array size but use ARRAY_SIZE instead.

---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +0 -0
index d3512f3..4ce4c1a 100644

drivers/gpu/drm/amd/amdgpu/dce_v6_0.c static int dce_v6_0_hpd_irq(struct amdgpu_device *adev, · line 2785

Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -1
@@ -2782,7 +2782,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,
        uint32_t disp_int, mask, int_control, tmp;
        unsigned hpd;
 
-       if (entry->src_data > 6) {
+       if (entry->src_data >= ARRAY_SIZE(interrupt_status_offsets)) {

This should actually be adev->mode_info.num_hpd as some asic variants may not have 6 hpd lines. Thanks for catching this.

Alex

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +0 -1
                DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
                return 0;
        }
--

2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#2 lore raw
Quoted 20 lines · Alex Deucher
Quoted 19 lines · Colin King

From: Colin Ian King <[email protected]>

The check for an out of bound index into array interrupt_status_offsets is off-by-one. Fix this and also don't compared to a hard coded array size but use ARRAY_SIZE instead.

---
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +0 -0
index d3512f3..4ce4c1a 100644
@@ -2782,7 +2782,7 @@ static int dce_v6_0_hpd_irq(struct amdgpu_device *adev,
        uint32_t disp_int, mask, int_control, tmp;
        unsigned hpd;
 
Quoted 7 lines

drivers/gpu/drm/amd/amdgpu/dce_v6_0.c static int dce_v6_0_hpd_irq(struct amdgpu_device *adev, · line 2785

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +1 -1
-       if (entry->src_data > 6) {
+       if (entry->src_data >= ARRAY_SIZE(interrupt_status_offsets)) {

This should actually be adev->mode_info.num_hpd as some asic variants may not have 6 hpd lines. Thanks for catching this.

Alex

Ah, that's a better way, so:

	if (entry->src_data >= adev->mode_info.num_hpd) {
	...

I'll send V2

Quoted 11 lines
Quoted 11 lines
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +0 -1
                DRM_DEBUG("Unhandled interrupt: %d %d\n", entry->src_id, entry->src_data);
                return 0;
        }
--

2.9.3

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel