]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/amdgpu: add first record offset check
authorGangliang Xie <ganglxie@amd.com>
Tue, 12 May 2026 07:05:16 +0000 (15:05 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 19 May 2026 15:52:53 +0000 (11:52 -0400)
check the upper and lower limits of first record offset

Signed-off-by: Gangliang Xie <ganglxie@amd.com>
Reviewed-by: Tao Zhou <tao.zhou1@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c

index 5e35a6c14149727e7d0eaedf4100e02fe9ab3f43..c61389a079822e8da60eae6abca1c44e2ba8b018 100644 (file)
@@ -1634,6 +1634,14 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
        }
 
        control->ras_fri = RAS_OFFSET_TO_INDEX(control, hdr->first_rec_offset);
+       if (hdr->first_rec_offset < control->ras_record_offset ||
+           control->ras_fri >= control->ras_max_record_count) {
+               dev_err(adev->dev,
+                       "RAS header invalid, ras_fri: %u, first_rec_offset:0x%x",
+                       control->ras_fri, hdr->first_rec_offset);
+               return -EINVAL;
+       }
+
        control->ras_num_mca_recs = 0;
        control->ras_num_pa_recs = 0;
        return 0;