Skip to content

Commit a5eab4f

Browse files
author
CIQ Kernel Automation
committed
drm/amdgpu: Fix potential out-of-bounds access in 'amdgpu_discovery_reg_base_init()'
jira VULN-37713 cve CVE-2024-27042 commit-author Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> commit cdb637d The issue arises when the array 'adev->vcn.vcn_config' is accessed before checking if the index 'adev->vcn.num_vcn_inst' is within the bounds of the array. The fix involves moving the bounds check before the array access. This ensures that 'adev->vcn.num_vcn_inst' is within the bounds of the array before it is used as an index. Fixes the below: drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c:1289 amdgpu_discovery_reg_base_init() error: testing array offset 'adev->vcn.num_vcn_inst' after use. Fixes: a0ccc71 ("drm/amdgpu/discovery: validate VCN and SDMA instances") Cc: Christian König <christian.koenig@amd.com> Cc: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit cdb637d) Signed-off-by: CIQ Kernel Automation <ciq_kernel_automation@ciq.com>
1 parent b4eb8c8 commit a5eab4f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,11 +1270,10 @@ static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
12701270
* 0b10 : encode is disabled
12711271
* 0b01 : decode is disabled
12721272
*/
1273-
adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1274-
ip->revision & 0xc0;
1275-
ip->revision &= ~0xc0;
12761273
if (adev->vcn.num_vcn_inst <
12771274
AMDGPU_MAX_VCN_INSTANCES) {
1275+
adev->vcn.vcn_config[adev->vcn.num_vcn_inst] =
1276+
ip->revision & 0xc0;
12781277
adev->vcn.num_vcn_inst++;
12791278
adev->vcn.inst_mask |=
12801279
(1U << ip->instance_number);
@@ -1285,6 +1284,7 @@ static int amdgpu_discovery_reg_base_init(struct amdgpu_device *adev)
12851284
adev->vcn.num_vcn_inst + 1,
12861285
AMDGPU_MAX_VCN_INSTANCES);
12871286
}
1287+
ip->revision &= ~0xc0;
12881288
}
12891289
if (le16_to_cpu(ip->hw_id) == SDMA0_HWID ||
12901290
le16_to_cpu(ip->hw_id) == SDMA1_HWID ||

0 commit comments

Comments
 (0)