Skip to contentSkip to conversation

drm/amdgpu: add check to avoid array bound issue

PATCH In review Guchun Chen 2 participants 2 messages Aug 8, 2019 1 message not in the archive

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

PATCH 1/1 drm/amdgpu: add check to avoid array bound issue

Sub_block_index can be passed from user level, so
add one check before accessing the array first to
prevent array index out of bound problem.

Change-Id I556fc560b44215848ba3a95f757febdf3d0af422
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -0
index 3e46cce60553..59c77b01c88a 100644
@@ -5960,6 +5960,9 @@ static int gfx_v9_0_ras_error_inject(struct amdgpu_device *adev,
 	if (adev->asic_type != CHIP_VEGA20)
 		return -EINVAL;
 
+	if (info->head.sub_block_index >= ARRAY_SIZE(ras_gfx_subblocks))
+		return -EINVAL;
+
 	if (!ras_gfx_subblocks[info->head.sub_block_index].name)
 		return -EPERM;
 
Signature · 6 lines
2.17.1

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

A message that is not in the archive (sent off-list or not yet received): [email protected]

Reviewed-by Tao Zhou
#2 lore raw
Quoted 38 lines

-----Original Message-----
From: amd-gfx <[email protected]> On Behalf Of Guchun Chen
Sent: 2019年8月8日 14:59
To: [email protected]; Zhang, Hawking <[email protected]>; Li, Dennis <[email protected]>; Pan, Xinhui <[email protected]>; Zhou1, Tao <[email protected]>
Cc: Chen, Guchun <[email protected]>
Subject: [PATCH] drm/amdgpu: add check to avoid array bound issue

Sub_block_index can be passed from user level, so add one check before accessing the array first to prevent array index out of bound problem.

Change-Id I556fc560b44215848ba3a95f757febdf3d0af422
---
 drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +3 -1
index 3e46cce60553..59c77b01c88a 100644
@@ -5960,6 +5960,9 @@ static int gfx_v9_0_ras_error_inject(struct
 amdgpu_device *adev,
 	if (adev->asic_type != CHIP_VEGA20)
 		return -EINVAL;
 
+	if (info->head.sub_block_index >= ARRAY_SIZE(ras_gfx_subblocks))
+		return -EINVAL;
+
 	if (!ras_gfx_subblocks[info->head.sub_block_index].name)
 		return -EPERM;
 
--

2.17.1

Quoted 4 lines

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

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